fix partial_string_tail panic (#530)

This commit is contained in:
Mark Thom
2020-05-18 11:14:27 -06:00
parent eecd809d9a
commit c14259060c
2 changed files with 15 additions and 4 deletions

View File

@@ -348,7 +348,9 @@ fn compile_into_module(
); );
match compile_into_module_impl(wam, &mut compiler, module, src, indices) { match compile_into_module_impl(wam, &mut compiler, module, src, indices) {
Ok(()) => EvalSession::EntrySuccess, Ok(()) => {
EvalSession::EntrySuccess
}
Err(e) => { Err(e) => {
compiler.drop_expansions(&mut wam.code_repo); compiler.drop_expansions(&mut wam.code_repo);
EvalSession::from(e) EvalSession::from(e)

View File

@@ -1154,10 +1154,19 @@ impl MachineState {
match pstr { match pstr {
Addr::PStrLocation(h, _) => { Addr::PStrLocation(h, _) => {
let tail = self.heap[h + 1].as_addr(h + 1); if let HeapCellValue::PartialString(_, true) = &self.heap[h] {
let target = self[temp_v!(2)]; let tail = self.heap[h + 1].as_addr(h + 1);
let target = self[temp_v!(2)];
self.unify(tail, target); self.unify(tail, target);
} else {
self.fail = true;
return Ok(());
}
}
Addr::EmptyList => {
self.fail = true;
return Ok(());
} }
_ => { _ => {
unreachable!() unreachable!()