fix: mono pass seeds env.globals for recursive top-level fn in class workspace
This commit is contained in:
@@ -463,6 +463,20 @@ pub fn collect_mono_targets(
|
||||
env.rigid_vars.insert(v.clone());
|
||||
}
|
||||
env.current_module = module_name.to_string();
|
||||
// Iter 22c (sibling of commit 5c5180f): seed `env.globals` from
|
||||
// the current module's fns so `synth`'s `Term::Var` lookup
|
||||
// (lib.rs:1678) resolves bare same-module references — most
|
||||
// importantly self-recursive top-level fns. Mirrors
|
||||
// `check_in_workspace` (lib.rs:1135-1139). Top-level fn names
|
||||
// are only per-module-unique (workspace-wide collisions are
|
||||
// legal), so seeding must be scoped to the current module —
|
||||
// unlike the workspace-wide flat `env.types` / `env.ctor_index`
|
||||
// tables that 5c5180f populated in `build_workspace_env`.
|
||||
if let Some(g) = env.module_globals.get(module_name).cloned() {
|
||||
for (n, t) in g {
|
||||
env.globals.insert(n, t);
|
||||
}
|
||||
}
|
||||
|
||||
let mut locals: IndexMap<String, Type> = IndexMap::new();
|
||||
for (n, t) in f.params.iter().zip(param_tys.iter()) {
|
||||
@@ -805,6 +819,14 @@ pub(crate) fn collect_residuals_ordered(
|
||||
env.rigid_vars.insert(v.clone());
|
||||
}
|
||||
env.current_module = module_name.to_string();
|
||||
// Iter 22c: same `env.globals` seeding as `collect_mono_targets`
|
||||
// — see the comment there for rationale. Both fns re-run `synth`
|
||||
// and must agree with the main check path's per-module env shape.
|
||||
if let Some(g) = env.module_globals.get(module_name).cloned() {
|
||||
for (n, t) in g {
|
||||
env.globals.insert(n, t);
|
||||
}
|
||||
}
|
||||
|
||||
let mut locals: IndexMap<String, Type> = IndexMap::new();
|
||||
for (n, t) in f.params.iter().zip(param_tys.iter()) {
|
||||
|
||||
Reference in New Issue
Block a user