feat(resolver): source-aware nominal leaf (Lowering-side) + ns-const tightening [stdlib E1]
Route the Lowering-side bare type leaf through the source-keyed caches (E0):
nominal author via collectVisibleAuthors(.user_bare_flat) + alias via
type_aliases_by_source, instead of the global findByName first-match. The
binding-free resolveAstType path + registration sites stay on the global
compat readers (move later). Single-author resolution byte-identical (no
shadows yet). Folded req #1: a namespaced-only import's const is no longer
bare-visible in array-dim/comptime-scalar position. Adds regression 0742
(ns-only bare const) and 0210 (generics/Vector/type-fn stay legacy).
Salvaged from a worker killed at the wall before commit; manager verified
the gate at ground truth (zig build test exit 0; run_examples 479/0 with
0210+0742 ok, prior 477 byte-identical; m3te ios-sim exit 0; folded fix
confirmed fail-before on master 7ffc0c1 exit 0 / pass-after exit 1).
This commit is contained in:
31
examples/0210-generics-resolver-legacy-paths.sx
Normal file
31
examples/0210-generics-resolver-legacy-paths.sx
Normal file
@@ -0,0 +1,31 @@
|
||||
// Resolver E1 lock: the bare-type-leaf cutover to the source-aware
|
||||
// `selectNominalLeaf` must NOT touch the NON-leaf type heads. A generic-struct
|
||||
// instantiation (`Box(s32)`), a `Vector(N, T)` builtin, and a type-returning
|
||||
// function (`Make(3, s64)`) are all resolved by `resolveTypeWithBindings`
|
||||
// ABOVE the bare-name leaf switch (`resolveParameterizedWithBindings` /
|
||||
// `resolveTypeCallWithBindings` / the `Vector` builtin path), so they stay on
|
||||
// the legacy resolution and never reach `selectNominalLeaf`. Parameterized
|
||||
// protocols share the same `resolveParameterizedWithBindings` pre-leaf path
|
||||
// (covered by 0204/0206). This example pins that all three still resolve
|
||||
// identically after the cutover.
|
||||
#import "modules/std.sx";
|
||||
|
||||
Box :: struct($T: Type) {
|
||||
value: T;
|
||||
}
|
||||
|
||||
Make :: ($K: u32, $T: Type) -> Type { return [K]T; }
|
||||
|
||||
N :: 3;
|
||||
|
||||
main :: () {
|
||||
b : Box(s32) = .{ value = 42 };
|
||||
print("box: {}\n", b.value);
|
||||
|
||||
v : Vector(4, f32) = .[1, 2, 3, 4];
|
||||
print("vec: {} {}\n", v.x, v.w);
|
||||
|
||||
a : Make(N, s64) = ---;
|
||||
a[0] = 10; a[2] = 30;
|
||||
print("typefn: len={} a0={} a2={}\n", a.len, a[0], a[2]);
|
||||
}
|
||||
Reference in New Issue
Block a user