throw permission_error in compile_assert when attempting to assert a built-in (#1872)

This commit is contained in:
Mark
2023-07-13 15:03:26 -06:00
parent a9cb826bf3
commit 12f890e4a2
4 changed files with 31 additions and 20 deletions

View File

@@ -3,6 +3,7 @@ use crate::parser::ast::*;
use crate::arena::*;
use crate::atom_table::*;
use crate::forms::*;
use crate::machine::ClauseType;
use crate::machine::loader::*;
use crate::machine::machine_state::*;
use crate::machine::streams::Stream;
@@ -259,6 +260,20 @@ pub struct IndexStore {
}
impl IndexStore {
pub(crate) fn builtin_property(&self, key: PredicateKey) -> bool {
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
};
} else {
true
}
}
#[inline(always)]
pub(crate) fn goal_expansion_defined(&self, key: PredicateKey) -> bool {
self.goal_expansion_indices.contains(&key)