From ba7b54e8f84ce87f9ef55774aa7f5f3582f46741 Mon Sep 17 00:00:00 2001 From: Mark Thom Date: Wed, 17 Sep 2025 19:43:37 -0700 Subject: [PATCH] fix attempted bind to bound StackVar (#3089) --- src/machine/dispatch.rs | 38 ++++++++++++++++++++++---------------- src/types.rs | 4 ++-- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/machine/dispatch.rs b/src/machine/dispatch.rs index 4d3c7666..c1b394c6 100644 --- a/src/machine/dispatch.rs +++ b/src/machine/dispatch.rs @@ -2802,6 +2802,28 @@ impl Machine { let mut h = 0; let mut string_cursor = string.as_str(); + if self.machine_st.heap[0].is_stack_var() { + let cell = self + .machine_st + .store(self.machine_st.deref(self.machine_st.heap[0])); + + if let Some(r) = cell.as_var() { + let target_cell = backtrack_on_resource_error!( + self.machine_st, + self.machine_st.heap.allocate_pstr(string_cursor) + ); + + self.machine_st.bind(r, target_cell); + self.machine_st.mode = MachineMode::Write; + + debug_assert!(!self.machine_st.fail); + + continue; + } + + self.machine_st.heap[0] = cell; + } + while let Some(c) = string_cursor.chars().next() { read_heap_cell!(self.machine_st.heap[h], (HeapCellValueTag::PStrLoc, pstr_loc) => { @@ -2911,22 +2933,6 @@ impl Machine { h = v; } } - (HeapCellValueTag::StackVar, s) => { - debug_assert_eq!(h, 0); - - let target_cell = backtrack_on_resource_error!( - self.machine_st, - self.machine_st.heap.allocate_pstr(string_cursor) - ); - - self.machine_st.bind( - Ref::stack_cell(s), - target_cell, - ); - - self.machine_st.mode = MachineMode::Write; - break; - } _ => { self.machine_st.fail = true; break; diff --git a/src/types.rs b/src/types.rs index 5cd95911..97df4bc4 100644 --- a/src/types.rs +++ b/src/types.rs @@ -125,9 +125,9 @@ pub(crate) enum RefTag { pub struct Ref { val: B56, #[allow(unused)] - m: bool, - #[allow(unused)] f: bool, + #[allow(unused)] + m: bool, tag: RefTag, } -- 2.54.0