correct clause/2 to work only on properly scoped terms
@@ -873,20 +873,25 @@ pub(super) fn system_call(&mut self,
&SystemClauseType::GetClause => {
let head = self[temp_v!(1)].clone();
- let subsection = match self.store(self.deref(head)) {
+ let (module, subsection) = match self.store(self.deref(head)) {
Addr::Str(s) =>
match self.heap[s].clone() {
HeapCellValue::NamedStr(arity, name, ..) =>
- indices.get_clause_subsection(name, arity),
+ (name.owning_module(), indices.get_clause_subsection(name, arity)),
_ => unreachable!()
},
Addr::Con(Constant::Atom(name, _)) =>
- indices.get_clause_subsection(name, 0),
+ (name.owning_module(), indices.get_clause_subsection(name, 0)),
_ => unreachable!()
};
match subsection {
Some(dynamic_predicate_info) => {
+ if dynamic_predicate_info.module_src != module {
+ self.fail = true;
+ return Ok(());
+ }
+
self.execute_at_index(2, dynamic_predicate_info.clauses_subsection_p);
return Ok(());
},
