]> Repositorios git - scryer-prolog.git/commitdiff
get rid of spurious warning, add type error for skip_max_list
authorMark Thom <[email protected]>
Mon, 21 May 2018 22:20:08 +0000 (16:20 -0600)
committerMark Thom <[email protected]>
Mon, 21 May 2018 22:20:08 +0000 (16:20 -0600)
src/prolog/ast.rs
src/prolog/machine/mod.rs
src/prolog/machine/system_calls.rs

index 5fac17a55c6b58bd429c0bd411d1dc9c636d3459..30d5ac5402d1b9b3f5c0295aec0255565e86a3e5 100644 (file)
@@ -1609,6 +1609,18 @@ pub enum IndexPtr {
 #[derive(Clone)]
 pub struct CodeIndex(pub Rc<RefCell<(IndexPtr, ClauseName)>>);
 
+impl CodeIndex {
+    pub fn is_undefined(&self) -> bool {
+        let index_ptr = self.0.borrow().0;
+        
+        if let IndexPtr::Undefined = index_ptr {
+            true
+        } else {
+            false
+        }
+    }
+}
+
 #[derive(Clone)]
 pub struct ModuleCodeIndex(pub IndexPtr, pub ClauseName);
 
index 6753fc914c6c4730a8b3f35d13c9f3f3e054ce89..ddbf0b37950ef6ed61955c97c6f4a8ef52f852f0 100644 (file)
@@ -57,7 +57,10 @@ impl<'a> SubModuleUser for MachineCodeIndex<'a> {
 
     fn insert_dir_entry(&mut self, name: ClauseName, arity: usize, idx: ModuleCodeIndex) {
         if let Some(ref mut code_idx) = self.code_dir.get_mut(&(name.clone(), arity)) {
-            println!("warning: overwriting {}/{}", &name, arity);
+            if !code_idx.is_undefined() {
+                println!("warning: overwriting {}/{}", &name, arity);
+            }
+            
             set_code_index!(code_idx, idx.0, idx.1);
 
             return;
index a48f766c5111fff0df5598784fc8f8e1f9bd0010..cd78785f3ec963f28c77d27ab9384931d0f036bb 100644 (file)
@@ -148,9 +148,14 @@ impl MachineState {
                 } else {
                     self.fail = true;
                 },
-            _ => {
+            Addr::HeapCell(_) | Addr::StackCell(..) => {
                 let stub = MachineError::functor_stub(clause_name!("$skip_max_list"), 4);
                 return Err(self.error_form(MachineError::instantiation_error(), stub));
+            },
+            addr => {
+                let stub = MachineError::functor_stub(clause_name!("$skip_max_list"), 4);
+                return Err(self.error_form(MachineError::type_error(ValidType::Integer, addr),
+                                           stub));
             }
         };