From: Mark Thom Date: Tue, 17 Apr 2018 15:26:13 +0000 (-0600) Subject: add predicate existence errors for failed metacalls. X-Git-Tag: v0.8.110~490^2 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=56318b09d0ec092c161ecc319d234a338680f65f;p=scryer-prolog.git add predicate existence errors for failed metacalls. --- 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();