diff --git a/examples/issue-0033-impl.sx b/examples/179-impl-visibility-impl.sx similarity index 61% rename from examples/issue-0033-impl.sx rename to examples/179-impl-visibility-impl.sx index b46995f..12539f3 100644 --- a/examples/issue-0033-impl.sx +++ b/examples/179-impl-visibility-impl.sx @@ -1,7 +1,7 @@ -// Helper that defines the impl. issue-0033's user file does NOT +// Helper that defines the impl. 179-impl-visibility's user file does NOT // directly import this — that's the whole point of the test. #import "modules/std.sx"; -#import "./issue-0033-types.sx"; +#import "./179-impl-visibility-types.sx"; impl Into(Wrap) for s64 { convert :: (self: s64) -> Wrap { diff --git a/examples/179-impl-visibility-types.sx b/examples/179-impl-visibility-types.sx new file mode 100644 index 0000000..5657465 --- /dev/null +++ b/examples/179-impl-visibility-types.sx @@ -0,0 +1,2 @@ +// Shared type for 179-impl-visibility — Wrap struct. +Wrap :: struct { v: s64 = 0; } diff --git a/examples/issue-0033-user.sx b/examples/179-impl-visibility-user.sx similarity index 58% rename from examples/issue-0033-user.sx rename to examples/179-impl-visibility-user.sx index 1acc8bd..bed2330 100644 --- a/examples/issue-0033-user.sx +++ b/examples/179-impl-visibility-user.sx @@ -1,7 +1,7 @@ // User file uses xx but only imports the shared types — NOT the impl. -// The Phase 4 visibility filter should reject the impl from issue-0033-impl.sx. +// The Phase 4 visibility filter should reject the impl from 179-impl-visibility-impl.sx. #import "modules/std.sx"; -#import "./issue-0033-types.sx"; +#import "./179-impl-visibility-types.sx"; run_user :: () -> s32 { w : Wrap = xx 7; diff --git a/examples/179-impl-visibility.sx b/examples/179-impl-visibility.sx new file mode 100644 index 0000000..e8ba6fa --- /dev/null +++ b/examples/179-impl-visibility.sx @@ -0,0 +1,21 @@ +// Impl visibility — an `impl Into(...) for ...` is registered into +// the global impl table when its module is imported anywhere in the +// program, but is only **visible** from files that themselves +// transitively import the impl's defining module. +// +// Setup: +// - 179-impl-visibility-impl.sx declares an `impl Into(Wrap) for s64`. +// - 179-impl-visibility-user.sx tries `xx 7 : Wrap` but only +// imports the shared types — NOT the impl module. +// - The xx at the user-file site must produce a "no visible xx +// conversion" diagnostic, not silently fall through to whatever +// was registered in another module. +// +// The diagnostic is the success criterion — the compile error is the +// expected output. Tests/expected/.txt captures it; .exit is 1. + +#import "modules/std.sx"; +#import "./179-impl-visibility-impl.sx"; +#import "./179-impl-visibility-user.sx"; + +main :: () -> s32 { run_user(); } diff --git a/examples/issue-0034-impl-a.sx b/examples/180-impl-duplicate-impl-a.sx similarity index 82% rename from examples/issue-0034-impl-a.sx rename to examples/180-impl-duplicate-impl-a.sx index f47adf8..093ef71 100644 --- a/examples/issue-0034-impl-a.sx +++ b/examples/180-impl-duplicate-impl-a.sx @@ -1,6 +1,6 @@ // Helper A — one of two conflicting impls for the same (s64, Wrap) pair. #import "modules/std.sx"; -#import "./issue-0034-types.sx"; +#import "./180-impl-duplicate-types.sx"; impl Into(Wrap) for s64 { convert :: (self: s64) -> Wrap { diff --git a/examples/issue-0034-impl-b.sx b/examples/180-impl-duplicate-impl-b.sx similarity index 82% rename from examples/issue-0034-impl-b.sx rename to examples/180-impl-duplicate-impl-b.sx index 0296cd2..c33bf83 100644 --- a/examples/issue-0034-impl-b.sx +++ b/examples/180-impl-duplicate-impl-b.sx @@ -1,6 +1,6 @@ // Helper B — second conflicting impl for the same (s64, Wrap) pair. #import "modules/std.sx"; -#import "./issue-0034-types.sx"; +#import "./180-impl-duplicate-types.sx"; impl Into(Wrap) for s64 { convert :: (self: s64) -> Wrap { diff --git a/examples/180-impl-duplicate-types.sx b/examples/180-impl-duplicate-types.sx new file mode 100644 index 0000000..4e4722e --- /dev/null +++ b/examples/180-impl-duplicate-types.sx @@ -0,0 +1,2 @@ +// Shared type for 180-impl-duplicate. +Wrap :: struct { v: s64 = 0; } diff --git a/examples/180-impl-duplicate.sx b/examples/180-impl-duplicate.sx new file mode 100644 index 0000000..2d1e2bc --- /dev/null +++ b/examples/180-impl-duplicate.sx @@ -0,0 +1,23 @@ +// Duplicate impl detection — two impls for the same (Source, Target) +// pair are both visible from the same `xx` site (because both their +// defining modules are transitively imported). The compiler must +// emit a "duplicate xx conversion" diagnostic naming both modules, +// not silently pick one or the other. +// +// Setup: +// - 180-impl-duplicate-impl-a.sx: `impl Into(Wrap) for s64` (mul by 10). +// - 180-impl-duplicate-impl-b.sx: `impl Into(Wrap) for s64` (add 100). +// - Main imports both; the `xx 7 : Wrap` site must error. +// +// Expected exit = 1, expected output = the focused diagnostic naming +// both impl modules. + +#import "modules/std.sx"; +#import "./180-impl-duplicate-impl-a.sx"; +#import "./180-impl-duplicate-impl-b.sx"; + +main :: () -> s32 { + w : Wrap = xx 7; + print("w.v = {}\n", w.v); + 0; +} diff --git a/examples/issue-0033-types.sx b/examples/issue-0033-types.sx deleted file mode 100644 index be0c07d..0000000 --- a/examples/issue-0033-types.sx +++ /dev/null @@ -1,2 +0,0 @@ -// Shared type for issue-0033 — Wrap struct. -Wrap :: struct { v: s64 = 0; } diff --git a/examples/issue-0033.sx b/examples/issue-0033.sx deleted file mode 100644 index ebfab91..0000000 --- a/examples/issue-0033.sx +++ /dev/null @@ -1,16 +0,0 @@ -// Phase 4 verification: an `impl Into(...) for ...` is registered into the -// global impl table when its module is imported anywhere in the program, but -// is only **visible** from files that themselves transitively import the impl's -// defining module. Here: -// - issue-0033-impl.sx declares an `impl Into(Wrap) for s64`. -// - issue-0033-user.sx tries to `xx 7 : Wrap` but only imports the shared -// types — not the impl module. -// - The xx at issue-0033-user.sx:7 must produce a clean "no visible xx -// conversion" diagnostic, not silently fall through to whatever was -// registered in another module. - -#import "modules/std.sx"; -#import "./issue-0033-impl.sx"; -#import "./issue-0033-user.sx"; - -main :: () -> s32 { run_user(); } diff --git a/examples/issue-0034-types.sx b/examples/issue-0034-types.sx deleted file mode 100644 index 2435224..0000000 --- a/examples/issue-0034-types.sx +++ /dev/null @@ -1,2 +0,0 @@ -// Shared type for issue-0034. -Wrap :: struct { v: s64 = 0; } diff --git a/examples/issue-0034.sx b/examples/issue-0034.sx deleted file mode 100644 index 4261b0e..0000000 --- a/examples/issue-0034.sx +++ /dev/null @@ -1,14 +0,0 @@ -// Phase 5 verification: two impls for the same (Source, Target) pair are -// both visible from the same xx site (because both their defining modules -// are transitively imported). The compiler must emit a clean -// "duplicate xx conversion" diagnostic naming both modules. - -#import "modules/std.sx"; -#import "./issue-0034-impl-a.sx"; -#import "./issue-0034-impl-b.sx"; - -main :: () -> s32 { - w : Wrap = xx 7; - print("w.v = {}\n", w.v); - 0; -} diff --git a/probe_0043 b/probe_0043 new file mode 100755 index 0000000..161821a Binary files /dev/null and b/probe_0043 differ diff --git a/probe_stdout b/probe_stdout new file mode 100755 index 0000000..e69de29 diff --git a/tests/expected/issue-0033.exit b/tests/expected/179-impl-visibility.exit similarity index 100% rename from tests/expected/issue-0033.exit rename to tests/expected/179-impl-visibility.exit diff --git a/tests/expected/179-impl-visibility.txt b/tests/expected/179-impl-visibility.txt new file mode 100644 index 0000000..d3d0181 --- /dev/null +++ b/tests/expected/179-impl-visibility.txt @@ -0,0 +1 @@ +/Users/agra/projects/sx/examples/./179-impl-visibility-user.sx:7:17: error: no visible xx conversion from 's64' to 'Wrap' — impl exists in another module but is not imported diff --git a/tests/expected/issue-0034.exit b/tests/expected/180-impl-duplicate.exit similarity index 100% rename from tests/expected/issue-0034.exit rename to tests/expected/180-impl-duplicate.exit diff --git a/tests/expected/180-impl-duplicate.txt b/tests/expected/180-impl-duplicate.txt new file mode 100644 index 0000000..c307e1d --- /dev/null +++ b/tests/expected/180-impl-duplicate.txt @@ -0,0 +1 @@ +/Users/agra/projects/sx/examples/180-impl-duplicate.sx:20:17: error: duplicate xx conversion from 's64' to 'Wrap': impls in /Users/agra/projects/sx/examples/./180-impl-duplicate-impl-a.sx and /Users/agra/projects/sx/examples/./180-impl-duplicate-impl-b.sx diff --git a/tests/expected/issue-0033.txt b/tests/expected/issue-0033.txt deleted file mode 100644 index efdfb76..0000000 --- a/tests/expected/issue-0033.txt +++ /dev/null @@ -1 +0,0 @@ -/Users/agra/projects/sx/examples/./issue-0033-user.sx:7:17: error: no visible xx conversion from 's64' to 'Wrap' — impl exists in another module but is not imported diff --git a/tests/expected/issue-0034.txt b/tests/expected/issue-0034.txt deleted file mode 100644 index dbd8bc1..0000000 --- a/tests/expected/issue-0034.txt +++ /dev/null @@ -1 +0,0 @@ -/Users/agra/projects/sx/examples/issue-0034.sx:11:17: error: duplicate xx conversion from 's64' to 'Wrap': impls in /Users/agra/projects/sx/examples/./issue-0034-impl-a.sx and /Users/agra/projects/sx/examples/./issue-0034-impl-b.sx