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>,
|
loader: &Loader<'a, Self>,
|
||||||
key: PredicateKey,
|
key: PredicateKey,
|
||||||
) -> Result<(), SessionError> {
|
) -> 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 let Some(builtins) = loader.wam_prelude.indices.modules.get(&atom!("builtins")) {
|
||||||
if builtins.module_decl.exports.contains(&ModuleExport::PredicateKey(key)) {
|
if builtins.module_decl.exports.contains(&ModuleExport::PredicateKey(key)) {
|
||||||
return Err(SessionError::CannotOverwriteBuiltIn(key));
|
return Err(SessionError::CannotOverwriteBuiltIn(key));
|
||||||
|
|||||||
@@ -264,11 +264,9 @@ impl IndexStore {
|
|||||||
let (name, arity) = key;
|
let (name, arity) = key;
|
||||||
|
|
||||||
if !ClauseType::is_inbuilt(name, arity) {
|
if !ClauseType::is_inbuilt(name, arity) {
|
||||||
return if let Some(module) = self.modules.get(&(atom!("builtins"))) {
|
self.modules.get(&(atom!("builtins")))
|
||||||
module.code_dir.contains_key(&(name, arity))
|
.map(|module| module.code_dir.contains_key(&(name, arity)))
|
||||||
} else {
|
.unwrap_or(false)
|
||||||
false
|
|
||||||
};
|
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user