From 56318b09d0ec092c161ecc319d234a338680f65f Mon Sep 17 00:00:00 2001 From: Mark Thom Date: Tue, 17 Apr 2018 09:26:13 -0600 Subject: [PATCH] add predicate existence errors for failed metacalls. --- src/prolog/machine/machine_state.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/prolog/machine/machine_state.rs b/src/prolog/machine/machine_state.rs index 049223f8..c76edba2 100644 --- a/src/prolog/machine/machine_state.rs +++ b/src/prolog/machine/machine_state.rs @@ -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(); -- 2.54.0