]> Repositorios git - scryer-prolog.git/commitdiff
current_predicate skips undefined predicates
authorMark Thom <[email protected]>
Tue, 5 Mar 2019 05:44:43 +0000 (22:44 -0700)
committerMark Thom <[email protected]>
Tue, 5 Mar 2019 05:44:43 +0000 (22:44 -0700)
src/prolog/machine/system_calls.rs

index bfdfe55eda1c162c1d5b6ab2bbef16bab0f56d6e..3b7bcb32721e785d9c3a971a073327ebb91b6847 100644 (file)
@@ -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));
                 }