]> Repositorios git - scryer-prolog.git/commitdiff
fix partial_string_tail panic (#530)
authorMark Thom <[email protected]>
Mon, 18 May 2020 17:14:27 +0000 (11:14 -0600)
committerMark Thom <[email protected]>
Mon, 18 May 2020 17:14:27 +0000 (11:14 -0600)
src/prolog/machine/compile.rs
src/prolog/machine/system_calls.rs

index c4842978b2195d77a2d22f393267312f190edbad..ac43d01cde5453529c70cf09242970e98cd343d9 100644 (file)
@@ -348,7 +348,9 @@ fn compile_into_module(
     );
 
     match compile_into_module_impl(wam, &mut compiler, module, src, indices) {
-        Ok(()) => EvalSession::EntrySuccess,
+        Ok(()) => {
+            EvalSession::EntrySuccess
+        }
         Err(e) => {
             compiler.drop_expansions(&mut wam.code_repo);
             EvalSession::from(e)
index 4061bdbc8731015000b92a21bf369a134606ba59..8281259e906ed668eef017c85a51363a26d130a7 100644 (file)
@@ -1154,10 +1154,19 @@ impl MachineState {
 
                 match pstr {
                     Addr::PStrLocation(h, _) => {
-                        let tail = self.heap[h + 1].as_addr(h + 1);
-                        let target = self[temp_v!(2)];
+                        if let HeapCellValue::PartialString(_, true) = &self.heap[h] {
+                            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!()