Value-const SELECTION was source-aware for emission/folding (F2/R1/F1), but expression TYPE inference still read the global last-wins `module_const_map`, so an inferred return type / coercion on a same-name const borrowed another module's const TYPE (mixed-type same-name consts were never exercised by the attempt-1 same-typed goldens). - expr_typer.zig: the `.identifier` const path now selects via the source-aware `selectModuleConst` (own-wins / one-flat-visible) instead of the global `module_const_map`. The global map still gates "is this a const name?"; an unpartitioned registration-only author emits its global type, and an ambiguous bare reference yields `.unresolved` (the emission path diagnoses loudly). - lower.zig: expose `selectModuleConst` so the type-inference path shares the one author selector emission/folding already use. Audited every `module_const_map` read: emission (4102) and global-init copy (1447) were already source-aware (attempt-1); the binds-a-value predicate (6400) is a boolean, not a type read; the in-`selectModuleConst` read (13842) is the unwired fallback. No sibling inference site leaks. examples: 0793 mixed-type own-wins inference (A's `K:s32` yields `1`, not the global `f64`'s `1.000000`); 0794 mixed-type bare → loud ambiguous (exit 1), the inference change does not mask the ambiguity. Prior E5 surfaces (0786-0792), the 0105 set (0752-0758), E1-E4 type surfaces (0763-0785) and FFI byte-identical; 533 markers green.
17 lines
849 B
Plaintext
17 lines
849 B
Plaintext
// issue 0105 / F4 — same-name VALUE const TYPE inference is source-aware. Two
|
|
// flat-imported modules each declare a top-level `K` with a DIFFERENT declared
|
|
// TYPE (A: `s32`, B: `f64`) and an inferred-return function that reads `K` bare.
|
|
// The inferred return type must come from each module's OWN `K` (own-wins), not
|
|
// the global last-wins const TYPE: `a_k` infers A's `s32` and yields the integer
|
|
// `1` (printed `1`, not `1.000000`), while `b_k` infers B's `f64` and yields
|
|
// `2.500000`. Selection routes through the source-aware `selectModuleConst`, the
|
|
// same author selector emission/folding use — type inference must agree.
|
|
#import "modules/std.sx";
|
|
#import "0793-modules-same-name-const-type-infer/a.sx";
|
|
#import "0793-modules-same-name-const-type-infer/b.sx";
|
|
|
|
main :: () -> s32 {
|
|
print("a={} b={}\n", a_k(), b_k());
|
|
0
|
|
}
|