fix(0114): gate alias-qualified calls to one-level carry, pin to target
The lowerCall namespace branch routed alias.fn() through the global qualified registration (first-wins) at any import depth, and through the global last-wins bare map for comptime/generic members. Plain-identifier alias roots now resolve via the carry-aware namespaceAliasVerdict: - visible alias (own edge or ONE flat hop): the member dispatches the TARGET module's own fn (namespaceFnMember + fd-keyed bareAuthorFuncId), so two modules' same-named aliases each call their own target. - two direct flat imports carrying the alias to distinct targets: loud ambiguity diagnostic. - alias only reachable beyond one hop: "namespace 'X' is not visible". - foreign / builtin / #compiler members keep the literal-symbol path. Regressions: examples 0832 (two-hop), 0833 (carried collision), 0834 (own-target pin / first-wins repair).
This commit is contained in:
15
examples/0832-modules-namespace-alias-two-hop-not-visible.sx
Normal file
15
examples/0832-modules-namespace-alias-two-hop-not-visible.sx
Normal file
@@ -0,0 +1,15 @@
|
||||
// Namespace aliases carry ONE level: an alias declared by a module is
|
||||
// usable in that module's DIRECT flat importers only. Two flat hops away
|
||||
// (`facade.sx` declares `t`, `facade2.sx` flat-imports facade, this file
|
||||
// flat-imports facade2) the alias is NOT visible — the carry does not
|
||||
// chain, mirroring bare-name non-transitivity (0763).
|
||||
//
|
||||
// Regression (issue 0114): the bare `alias.fn()` call path used to serve
|
||||
// this from the global qualified registration at any import depth.
|
||||
|
||||
#import "modules/std.sx";
|
||||
#import "0832-modules-namespace-alias-two-hop-not-visible/facade2.sx";
|
||||
|
||||
main :: () {
|
||||
print("{}\n", t.helper());
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
t :: #import "target.sx";
|
||||
@@ -0,0 +1 @@
|
||||
#import "facade.sx";
|
||||
@@ -0,0 +1 @@
|
||||
helper :: () -> s64 { 7 }
|
||||
@@ -0,0 +1,15 @@
|
||||
// Two direct flat imports each declare the SAME alias name `t` pointing at
|
||||
// DIFFERENT targets. Using the carried alias here is ambiguous and rejected
|
||||
// loudly — never a silent first-registration pick. (Each module's own use
|
||||
// of its own `t` stays valid — see 0834.)
|
||||
//
|
||||
// Regression (issue 0114): collisions used to resolve silently first-wins
|
||||
// through the global qualified-fn registration.
|
||||
|
||||
#import "modules/std.sx";
|
||||
#import "0833-modules-namespace-alias-carried-collision-ambiguous/a.sx";
|
||||
#import "0833-modules-namespace-alias-carried-collision-ambiguous/b.sx";
|
||||
|
||||
main :: () {
|
||||
print("{} {} {}\n", use_a(), use_b(), t.fx());
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
t :: #import "x.sx";
|
||||
use_a :: () -> s64 { t.fx() }
|
||||
@@ -0,0 +1,2 @@
|
||||
t :: #import "y.sx";
|
||||
use_b :: () -> s64 { t.fy() }
|
||||
@@ -0,0 +1 @@
|
||||
fx :: () -> s64 { 1 }
|
||||
@@ -0,0 +1 @@
|
||||
fy :: () -> s64 { 2 }
|
||||
15
examples/0834-modules-namespace-alias-own-target-pin.sx
Normal file
15
examples/0834-modules-namespace-alias-own-target-pin.sx
Normal file
@@ -0,0 +1,15 @@
|
||||
// Two modules each declare their OWN alias `t` to different targets, and the
|
||||
// targets export the SAME member name `f`. Each module's `t.f()` dispatches
|
||||
// its OWN target's `f` — a.sx gets x.sx's (1), b.sx gets y.sx's (2). The
|
||||
// caller here never uses `t` itself, so no ambiguity arises.
|
||||
//
|
||||
// Regression (issue 0114): the global qualified-fn map registered `t.f`
|
||||
// first-wins, so both modules used to call whichever registered first.
|
||||
|
||||
#import "modules/std.sx";
|
||||
#import "0834-modules-namespace-alias-own-target-pin/a.sx";
|
||||
#import "0834-modules-namespace-alias-own-target-pin/b.sx";
|
||||
|
||||
main :: () {
|
||||
print("{} {}\n", use_a(), use_b());
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
t :: #import "x.sx";
|
||||
use_a :: () -> s64 { t.f() }
|
||||
@@ -0,0 +1,2 @@
|
||||
t :: #import "y.sx";
|
||||
use_b :: () -> s64 { t.f() }
|
||||
@@ -0,0 +1 @@
|
||||
f :: () -> s64 { 1 }
|
||||
@@ -0,0 +1 @@
|
||||
f :: () -> s64 { 2 }
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,5 @@
|
||||
error: namespace 't' is not visible; #import the module that declares it
|
||||
--> examples/0832-modules-namespace-alias-two-hop-not-visible.sx:14:19
|
||||
|
|
||||
14 | print("{}\n", t.helper());
|
||||
| ^
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
1
|
||||
@@ -0,0 +1,5 @@
|
||||
error: namespace 't' is ambiguous: aliases from multiple flat-imported modules point at different targets; declare the alias locally
|
||||
--> examples/0833-modules-namespace-alias-carried-collision-ambiguous.sx:14:43
|
||||
|
|
||||
14 | print("{} {} {}\n", use_a(), use_b(), t.fx());
|
||||
| ^
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
0
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
1 2
|
||||
Reference in New Issue
Block a user