From: Mark Thom Date: Tue, 5 Mar 2019 05:44:43 +0000 (-0700) Subject: current_predicate skips undefined predicates X-Git-Tag: v0.8.110~210 X-Git-Url: https://git.sagredo.dev/?a=commitdiff_plain;h=e51e8161784b51da0ba36d95df22678171130363;p=scryer-prolog.git current_predicate skips undefined predicates --- 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)); }