]> Repositorios git - scryer-prolog.git/commitdiff
fix keysort error detection bugs
authorMark Thom <[email protected]>
Thu, 3 May 2018 03:52:34 +0000 (21:52 -0600)
committerMark Thom <[email protected]>
Thu, 3 May 2018 03:52:34 +0000 (21:52 -0600)
src/prolog/machine/machine_errors.rs
src/prolog/machine/machine_state_impl.rs

index 9fe771cd072fc87e4a16843fa574644e7f30687a..118612914211eb6214082d3dd31b929e9abb15e6 100644 (file)
@@ -56,10 +56,12 @@ impl MachineState {
             _ => {
                 let mut addr = sorted;
 
-                while let Addr::Lis(mut l) = self.store(self.deref(addr)) {
+                while let Addr::Lis(l) = self.store(self.deref(addr)) {
+                    let mut new_l = l;
+                    
                     loop {
-                        match self.heap[l].clone() {
-                            HeapCellValue::Addr(Addr::Str(new_l)) => l = new_l,
+                        match self.heap[new_l].clone() {
+                            HeapCellValue::Addr(Addr::Str(l)) => new_l = l,
                             HeapCellValue::NamedStr(2, ref name, Some(Fixity::In))
                                 if name.as_str() == "-" => break,
                             HeapCellValue::Addr(Addr::HeapCell(_)) => break,
@@ -69,7 +71,7 @@ impl MachineState {
                         };
                     }
 
-                    addr = Addr::HeapCell(l + 2);
+                    addr = self.store(self.deref(Addr::HeapCell(l + 1)));
                 }
 
                 Ok(())
index e393470a2ff7473a4a2aca10a009c1fabe3393dd..b6f0d1d35cc57177b7ff86799a1a2248d23e9010 100644 (file)
@@ -1716,7 +1716,7 @@ impl MachineState {
                         HeapCellValue::Addr(Addr::Con(Constant::EmptyList)) =>
                             break,
                         hcv =>
-                            return Err(self.type_error(ValidType::List, hcv.as_addr(l)))
+                            return Err(self.type_error(ValidType::List, a1))
                     };
                 }