From 5dddf0a4604380820ab0f3e5f3b3ebb7e84c5011 Mon Sep 17 00:00:00 2001 From: Mark Thom Date: Wed, 19 Jan 2022 20:51:23 -0700 Subject: [PATCH] dereference car of Lis in HeapPStRIter::step (#1238) --- src/machine/partial_string.rs | 15 +++++++++++++-- tests/scryer/src_tests.rs | 4 ++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/machine/partial_string.rs b/src/machine/partial_string.rs index 4430b9e3..ed1ad919 100644 --- a/src/machine/partial_string.rs +++ b/src/machine/partial_string.rs @@ -1,6 +1,7 @@ use crate::atom_table::*; use crate::parser::ast::*; +use crate::machine::heap::*; use crate::machine::machine_errors::CycleSearchResult; use crate::machine::system_calls::BrentAlgState; use crate::types::*; @@ -296,7 +297,12 @@ impl<'a> HeapPStrIter<'a> { }; } (HeapCellValueTag::Lis, h) => { - return if let Some(c) = self.heap[h].as_char() { + let value = heap_bound_store( + self.heap, + heap_bound_deref(self.heap, self.heap[h]), + ); + + return if let Some(c) = value.as_char() { Some(PStrIterStep { iteratee: PStrIteratee::Char(curr_hare, c), next_hare: h+1, @@ -310,7 +316,12 @@ impl<'a> HeapPStrIter<'a> { .get_name_and_arity(); return if name == atom!(".") && arity == 2 { - if let Some(c) = self.heap[s+1].as_char() { + let value = heap_bound_store( + self.heap, + heap_bound_deref(self.heap, self.heap[s+1]), + ); + + if let Some(c) = value.as_char() { Some(PStrIterStep { iteratee: PStrIteratee::Char(curr_hare, c), next_hare: s+2, diff --git a/tests/scryer/src_tests.rs b/tests/scryer/src_tests.rs index 56aa7374..24259f3a 100644 --- a/tests/scryer/src_tests.rs +++ b/tests/scryer/src_tests.rs @@ -51,7 +51,7 @@ fn rules() { fn setup_call_cleanup_load() { load_module_test( "src/tests/setup_call_cleanup.pl", - "1+21+31+2>_14313+_143141+_129071+2>41+2>_143141+2>31+2>31+2>4ba" + "1+21+31+2>_14219+_142201+_128131+2>41+2>_142201+2>31+2>31+2>4ba" ); } @@ -60,7 +60,7 @@ fn setup_call_cleanup_process() { run_top_level_test_with_args( &["src/tests/setup_call_cleanup.pl", "-f", "-g", "halt"], "", - "1+21+31+2>_15712+_157131+_143061+2>41+2>_157131+2>31+2>31+2>4ba", + "1+21+31+2>_15618+_156191+_142121+2>41+2>_156191+2>31+2>31+2>4ba" ); } -- 2.54.0