add is_inbuilt check to err_on_builtin_overwrite (#1872)
This commit is contained in:
@@ -328,6 +328,10 @@ impl<'a> LoadState<'a> for LiveLoadAndMachineState<'a> {
|
||||
loader: &Loader<'a, Self>,
|
||||
key: PredicateKey,
|
||||
) -> Result<(), SessionError> {
|
||||
if ClauseType::is_inbuilt(key.0, key.1) {
|
||||
return Err(SessionError::CannotOverwriteBuiltIn(key));
|
||||
}
|
||||
|
||||
if let Some(builtins) = loader.wam_prelude.indices.modules.get(&atom!("builtins")) {
|
||||
if builtins.module_decl.exports.contains(&ModuleExport::PredicateKey(key)) {
|
||||
return Err(SessionError::CannotOverwriteBuiltIn(key));
|
||||
|
||||
@@ -264,11 +264,9 @@ impl IndexStore {
|
||||
let (name, arity) = key;
|
||||
|
||||
if !ClauseType::is_inbuilt(name, arity) {
|
||||
return if let Some(module) = self.modules.get(&(atom!("builtins"))) {
|
||||
module.code_dir.contains_key(&(name, arity))
|
||||
} else {
|
||||
false
|
||||
};
|
||||
self.modules.get(&(atom!("builtins")))
|
||||
.map(|module| module.code_dir.contains_key(&(name, arity)))
|
||||
.unwrap_or(false)
|
||||
} else {
|
||||
true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user