fix: mono pass seeds env.types and env.ctor_index for user ADTs

This commit is contained in:
2026-05-09 22:43:54 +02:00
parent 59e86b3805
commit 5c5180fc48
+24
View File
@@ -403,6 +403,30 @@ pub fn build_workspace_env(ws: &Workspace) -> crate::Env {
}
}
}
// Iter 22c: seed `env.types` and `env.ctor_index` from every
// module's `Def::Type` entries. `synth`'s bare-name `Term::Ctor`
// path (and three sibling sites in `lib.rs`) consult these flat
// tables; without them, re-running `synth` on an instance method
// body whose type references a user ADT yields `UnknownType`.
// Workspace-wide flat tables are safe here because `check_workspace`
// has already accepted the workspace, so duplicate names cannot
// occur. Mirrors `check_in_workspace` (lib.rs:1099-1128).
for m in ws.modules.values() {
for d in &m.defs {
if let Def::Type(td) = d {
for c in &td.ctors {
env.ctor_index.insert(
c.name.clone(),
crate::CtorRef {
type_name: td.name.clone(),
},
);
}
env.types.insert(td.name.clone(), td.clone());
}
}
}
env
}