diff --git a/crates/ailang-codegen/src/lib.rs b/crates/ailang-codegen/src/lib.rs index 30f5958..b9ce52d 100644 --- a/crates/ailang-codegen/src/lib.rs +++ b/crates/ailang-codegen/src/lib.rs @@ -376,6 +376,20 @@ fn lower_workspace_inner(ws: &Workspace, alloc: AllocStrategy) -> Result let key = imp.alias.clone().unwrap_or_else(|| imp.module.clone()); import_map.insert(key, imp.module.clone()); } + // Iter 23.2 (fourth lockstep site, after Pattern::Ctor 15a / + // Term::Ctor typecheck / lookup_ctor_by_type codegen): mirror + // the typechecker's implicit-prelude import injection + // (crates/ailang-check/src/lib.rs:1198 and :1300). User + // modules that call prelude-resident fns synthesised by Iter + // 22b.3 monomorphisation (e.g. `prelude.eq__Int` from a user + // calling `eq x y` on Ints) need the codegen-side import_map + // to resolve the `prelude.` prefix at the call site + // (`lower_call`'s prefix lookup). + if m.name != "prelude" { + import_map + .entry("prelude".to_string()) + .or_insert_with(|| "prelude".to_string()); + } let mut emitter = Emitter::new( m,