iter 23.1.4 fixup: local-hit with mismatching type_name falls through to imports-fallback
This commit is contained in:
@@ -1679,20 +1679,22 @@ impl<'a> Emitter<'a> {
|
||||
}
|
||||
Ok(cref)
|
||||
} else {
|
||||
// Local-first: current module's ctor table wins on conflict.
|
||||
// Local-first: current module's ctor table wins on a
|
||||
// type-matching hit. A local ctor with the same name but
|
||||
// a DIFFERENT `type_name` is not a conflict — typecheck
|
||||
// has already pinned which type is meant, so the lookup
|
||||
// falls through to the imports-fallback. Only an
|
||||
// exhausted scan yields `Err`.
|
||||
if let Some(cref) = self
|
||||
.module_ctor_index
|
||||
.get(self.module_name)
|
||||
.and_then(|m| m.get(ctor_name))
|
||||
.cloned()
|
||||
{
|
||||
if cref.type_name != type_name {
|
||||
return Err(CodegenError::Internal(format!(
|
||||
"ctor `{ctor_name}` belongs to `{}`, not `{type_name}`",
|
||||
cref.type_name
|
||||
)));
|
||||
if cref.type_name == type_name {
|
||||
return Ok(cref);
|
||||
}
|
||||
return Ok(cref);
|
||||
// type_name mismatch — keep looking in imports.
|
||||
}
|
||||
// Iter 23.1: fallback — scan other modules for a bare ctor
|
||||
// whose declared `type_name` matches. The typechecker has
|
||||
@@ -1711,7 +1713,7 @@ impl<'a> Emitter<'a> {
|
||||
}
|
||||
}
|
||||
Err(CodegenError::Internal(format!(
|
||||
"unknown ctor `{ctor_name}` in module `{}`",
|
||||
"unknown ctor `{ctor_name}` for type `{type_name}` in module `{}`",
|
||||
self.module_name
|
||||
)))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user