From e51e8161784b51da0ba36d95df22678171130363 Mon Sep 17 00:00:00 2001 From: Mark Thom Date: Mon, 4 Mar 2019 22:44:43 -0700 Subject: [PATCH] current_predicate skips undefined predicates --- src/prolog/machine/system_calls.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/prolog/machine/system_calls.rs b/src/prolog/machine/system_calls.rs index bfdfe55e..3b7bcb32 100644 --- a/src/prolog/machine/system_calls.rs +++ b/src/prolog/machine/system_calls.rs @@ -371,12 +371,16 @@ impl MachineState { &SystemClauseType::GetCurrentPredicateList => { let mut addrs = vec![]; - for (name, arity) in indices.code_dir.keys().cloned() { + for ((name, arity), idx) in indices.code_dir.iter() { + if idx.is_undefined() { + continue; + } + let h = self.heap.h; self.heap.push(HeapCellValue::NamedStr(2, clause_name!("/"), Some((400, YFX)))); - self.heap.push(HeapCellValue::Addr(Addr::Con(Constant::Atom(name, None)))); - self.heap.push(heap_integer!(arity)); + self.heap.push(HeapCellValue::Addr(Addr::Con(Constant::Atom(name.clone(), None)))); + self.heap.push(heap_integer!(*arity)); addrs.push(Addr::Str(h)); } -- 2.54.0