fix keysort error detection bugs

This commit is contained in:
Mark Thom
2018-05-02 21:52:34 -06:00
parent 3c72441f68
commit d69bc4ed10
2 changed files with 7 additions and 5 deletions

View File

@@ -56,10 +56,12 @@ impl MachineState {
_ => { _ => {
let mut addr = sorted; 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 { loop {
match self.heap[l].clone() { match self.heap[new_l].clone() {
HeapCellValue::Addr(Addr::Str(new_l)) => l = new_l, HeapCellValue::Addr(Addr::Str(l)) => new_l = l,
HeapCellValue::NamedStr(2, ref name, Some(Fixity::In)) HeapCellValue::NamedStr(2, ref name, Some(Fixity::In))
if name.as_str() == "-" => break, if name.as_str() == "-" => break,
HeapCellValue::Addr(Addr::HeapCell(_)) => 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(()) Ok(())

View File

@@ -1716,7 +1716,7 @@ impl MachineState {
HeapCellValue::Addr(Addr::Con(Constant::EmptyList)) => HeapCellValue::Addr(Addr::Con(Constant::EmptyList)) =>
break, break,
hcv => hcv =>
return Err(self.type_error(ValidType::List, hcv.as_addr(l))) return Err(self.type_error(ValidType::List, a1))
}; };
} }