]> Repositorios git - scryer-prolog.git/commitdiff
don't replace undefined module predicates (#2232)
authorMark <[email protected]>
Mon, 18 Dec 2023 21:57:22 +0000 (14:57 -0700)
committerMark <[email protected]>
Mon, 18 Dec 2023 21:57:22 +0000 (14:57 -0700)
src/machine/load_state.rs

index 079ee29eb55cb63c9be200068d8326ae0b8853bd..456cfb9aa7b4ba73193905c271cde61bcb152efb 100644 (file)
@@ -497,19 +497,21 @@ impl<'a, LS: LoadState<'a>> Loader<'a, LS> {
         }
 
         for (key, code_index) in removed_module.code_dir.iter_mut() {
-            if skipped_local_predicates.contains(&key) {
+            if skipped_local_predicates.contains(key) {
                 continue;
             }
 
-            let old_index_ptr = code_index.replace(IndexPtr::undefined());
+            if !code_index.is_undefined() && !code_index.is_dynamic_undefined() {
+                let old_index_ptr = code_index.replace(IndexPtr::undefined());
 
-            self.payload
-                .retraction_info
-                .push_record(RetractionRecord::ReplacedModulePredicate(
-                    module_name,
-                    *key,
-                    old_index_ptr,
-                ));
+                self.payload
+                    .retraction_info
+                    .push_record(RetractionRecord::ReplacedModulePredicate(
+                        module_name,
+                        *key,
+                        old_index_ptr,
+                    ));
+            }
         }
 
         for (key, skeleton) in removed_module.extensible_predicates.drain(..) {