]> Repositorios git - scryer-prolog.git/commitdiff
add predicate existence errors for failed metacalls.
authorMark Thom <[email protected]>
Tue, 17 Apr 2018 15:26:13 +0000 (09:26 -0600)
committerMark Thom <[email protected]>
Tue, 17 Apr 2018 15:26:13 +0000 (09:26 -0600)
src/prolog/machine/machine_state.rs

index 049223f891ac9fdb44f1087bc02ee882d7e2c7ac..c76edba2a6e3a5c025e29dd48724c653460ef2f2 100644 (file)
@@ -426,17 +426,16 @@ pub(crate) trait CallPolicy: Any {
 
                 Ok(())
             },
-            &ClauseType::CallN => {
+            &ClauseType::CallN =>
                 if let Some((name, arity)) = machine_st.setup_call_n(arity) {
                     if let Some(idx) = code_dirs.get(name.clone(), arity, &machine_st.p.clone()) {
-                        return self.context_call(machine_st, name, arity, idx, lco);
+                        self.context_call(machine_st, name, arity, idx, lco)
                     } else {
-                        machine_st.fail = true;
+                        Err(predicate_existence_error(name, arity, machine_st.heap.h))
                     }
-                }
-
-                Ok(())
-            },
+                } else {
+                    Ok(())
+                },
             &ClauseType::Compare => {
                 let a1 = machine_st[temp_v!(1)].clone();
                 let a2 = machine_st[temp_v!(2)].clone();