correct clause/2 to work only on properly scoped terms

This commit is contained in:
Mark Thom
2019-03-07 22:55:54 -07:00
parent b1e47cc465
commit 933c19c317

View File

@@ -873,20 +873,25 @@ impl MachineState {
&SystemClauseType::GetClause => { &SystemClauseType::GetClause => {
let head = self[temp_v!(1)].clone(); 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) => Addr::Str(s) =>
match self.heap[s].clone() { match self.heap[s].clone() {
HeapCellValue::NamedStr(arity, name, ..) => HeapCellValue::NamedStr(arity, name, ..) =>
indices.get_clause_subsection(name, arity), (name.owning_module(), indices.get_clause_subsection(name, arity)),
_ => unreachable!() _ => unreachable!()
}, },
Addr::Con(Constant::Atom(name, _)) => Addr::Con(Constant::Atom(name, _)) =>
indices.get_clause_subsection(name, 0), (name.owning_module(), indices.get_clause_subsection(name, 0)),
_ => unreachable!() _ => unreachable!()
}; };
match subsection { match subsection {
Some(dynamic_predicate_info) => { 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); self.execute_at_index(2, dynamic_predicate_info.clauses_subsection_p);
return Ok(()); return Ok(());
}, },