qualify module quantification errors better (#2685)
This commit is contained in:
@@ -1311,17 +1311,22 @@ impl Machine {
|
|||||||
fn quantification_to_module_name(
|
fn quantification_to_module_name(
|
||||||
&mut self,
|
&mut self,
|
||||||
quantification: ModuleQuantification,
|
quantification: ModuleQuantification,
|
||||||
src: HeapCellValue,
|
|
||||||
) -> Result<Atom, MachineError> {
|
) -> Result<Atom, MachineError> {
|
||||||
match quantification.specified() {
|
match quantification.specified() {
|
||||||
Some(module_name) => {
|
Some(module_name) => {
|
||||||
let module_name = self.machine_st.store(self.machine_st.deref(module_name));
|
let module_name = self.machine_st.store(self.machine_st.deref(module_name));
|
||||||
|
|
||||||
if module_name.get_tag() == HeapCellValueTag::Atom {
|
read_heap_cell!(module_name,
|
||||||
Ok(cell_as_atom!(module_name))
|
(HeapCellValueTag::Atom, (module_name, _arity)) => {
|
||||||
} else {
|
Ok(module_name)
|
||||||
Err(self.machine_st.type_error(ValidType::Atom, src))
|
}
|
||||||
}
|
(HeapCellValueTag::Var) => {
|
||||||
|
Err(self.machine_st.instantiation_error())
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
Err(self.machine_st.type_error(ValidType::Atom, module_name))
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
None => Ok(if let Some(load_context) = self.load_contexts.last() {
|
None => Ok(if let Some(load_context) = self.load_contexts.last() {
|
||||||
load_context.module
|
load_context.module
|
||||||
@@ -1389,7 +1394,7 @@ impl Machine {
|
|||||||
|
|
||||||
let mut arity = arity + goal_arity;
|
let mut arity = arity + goal_arity;
|
||||||
let mut module_name = self
|
let mut module_name = self
|
||||||
.quantification_to_module_name(module_quantification, self.machine_st.registers[1])
|
.quantification_to_module_name(module_quantification)
|
||||||
.map_err(|err| {
|
.map_err(|err| {
|
||||||
let stub = functor_stub(atom!("call"), arity);
|
let stub = functor_stub(atom!("call"), arity);
|
||||||
self.machine_st.error_form(err, stub)
|
self.machine_st.error_form(err, stub)
|
||||||
@@ -1410,10 +1415,7 @@ impl Machine {
|
|||||||
self.machine_st.name_and_arity_from_heap(goal)
|
self.machine_st.name_and_arity_from_heap(goal)
|
||||||
{
|
{
|
||||||
module_name = self
|
module_name = self
|
||||||
.quantification_to_module_name(
|
.quantification_to_module_name(module_quantification)
|
||||||
module_quantification,
|
|
||||||
self.machine_st.registers[1],
|
|
||||||
)
|
|
||||||
.unwrap_or(module_name);
|
.unwrap_or(module_name);
|
||||||
|
|
||||||
arity -= goal_arity;
|
arity -= goal_arity;
|
||||||
|
|||||||
Reference in New Issue
Block a user