]> Repositorios git - scryer-prolog.git/commitdiff
protect imported predicates from being overwritten (re: issue #28)
authorMark Thom <[email protected]>
Mon, 23 Apr 2018 21:55:53 +0000 (15:55 -0600)
committerMark Thom <[email protected]>
Mon, 23 Apr 2018 21:55:53 +0000 (15:55 -0600)
src/prolog/io.rs
src/prolog/machine/mod.rs

index 9d12260e940b51155033f390a0efef10a3abb55b..8459f1162788734d08ef6cdd4a3d79969881edf3 100644 (file)
@@ -267,7 +267,7 @@ impl fmt::Display for EvalError {
             &EvalError::ModuleDoesNotContainExport => write!(f, "module does not contain claimed export."),
             &EvalError::QueryFailure => write!(f, "false."),
             &EvalError::QueryFailureWithException(ref e) => write!(f, "{}", error_string(e)),
-            &EvalError::ImpermissibleEntry(ref msg) => write!(f, "cannot overwrite builtin {}.", msg),
+            &EvalError::ImpermissibleEntry(ref msg) => write!(f, "cannot overwrite {}.", msg),
             &EvalError::OpIsInfixAndPostFix =>
                 write!(f, "cannot define an op to be both postfix and infix."),
             &EvalError::NamelessEntry => write!(f, "the predicate head is not an atom or clause."),
index efce38ce7d1efba4748bcf2c66f6bbe7b2238c55..f9c1a621b706035a820553501d92ae41a93129a9 100644 (file)
@@ -190,12 +190,10 @@ impl Machine {
                          -> EvalSession
     {
         match self.code_dir.get(&(name.clone(), arity)) {
-            Some(&CodeIndex (ref idx)) =>
-                if idx.borrow().1 == clause_name!("builtin") {
+            Some(&CodeIndex (ref idx)) if idx.borrow().1 != clause_name!("user") =>
                     return EvalSession::from(EvalError::ImpermissibleEntry(format!("{}/{}",
                                                                                    name,
-                                                                                   arity)))
-                },
+                                                                                   arity))),                
             _ => {}
         };