test/wcc: 989_declns_sep decl-namespace gate — dup reject / builtin redecl / dir-pkg modfn coexist (M4 E2-C2c, #22)
Final E2-C2 commit. New decl-namespace gate, both stages: dup fn/type/def/let build-FAIL with a right-reason "duplicate <kind> <name>" diag (shared substring; ww has no line:col); builtin_redecl ACCEPT exit 7 (shadowing a pre-seeded builtin is redeclarable); modfn coexist reshaped to a real directory package (696 precedent) via ww build --sep on two layouts (modfn_coexist + _vbu use-before-value) so both run to 6, cs==ww per-pkg .s/.wwi/.unit.ww, cross-order byte-id on .s/.wwi (.unit.ww excluded: verbatim source flips by construction, order-independence is codegen). __root.s carries both CALL aa.helper and CALL main.aa distinctly. Test-only; all 5 pins hold; 443 to 444.
This commit is contained in:
5
test/wcc/data/modfn_coexist/aa/aa.ww
Normal file
5
test/wcc/data/modfn_coexist/aa/aa.ww
Normal file
@@ -0,0 +1,5 @@
|
||||
// #30 dir-package — the imported module `aa`. Paired with ../main.ww,
|
||||
// whose primary package also declares a value-namespace `fn aa`. Driver:
|
||||
// the modfn_coexist leg of the decl-namespace gate (NNN_declns_sep.c).
|
||||
package aa;
|
||||
export fn helper() i32 = { return 5; };
|
||||
11
test/wcc/data/modfn_coexist/main.ww
Normal file
11
test/wcc/data/modfn_coexist/main.ww
Normal file
@@ -0,0 +1,11 @@
|
||||
// #30 dir-package coexistence — the value-namespace `fn aa` and the
|
||||
// imported MODULE `aa` (SK_USE) coexist. `aa()` binds the local fn (a
|
||||
// module is not callable); `aa.helper()` binds through the module (the
|
||||
// fn has no field `helper`). Both must resolve, so any mis-resolution
|
||||
// fails to COMPILE; running to 1+5=6 proves both bind. The dir-package
|
||||
// reshape of the dying single-file modfn_coexist_ok.ww (M4 amalgamation
|
||||
// shape retired at the flip).
|
||||
package main;
|
||||
import aa;
|
||||
fn aa() i32 = { return 1; };
|
||||
export fn main() i32 = { return aa() + aa.helper(); };
|
||||
6
test/wcc/data/modfn_coexist_vbu/aa/aa.ww
Normal file
6
test/wcc/data/modfn_coexist_vbu/aa/aa.ww
Normal file
@@ -0,0 +1,6 @@
|
||||
// #30 dir-package — the imported module `aa` for the VALUE-BEFORE-USE
|
||||
// twin. Identical to ../../modfn_coexist/aa/aa.ww; kept as its own dir so
|
||||
// the two layouts are independently buildable. Driver: the
|
||||
// modfn_coexist_vbu leg of the decl-namespace gate (NNN_declns_sep.c).
|
||||
package aa;
|
||||
export fn helper() i32 = { return 5; };
|
||||
12
test/wcc/data/modfn_coexist_vbu/main.ww
Normal file
12
test/wcc/data/modfn_coexist_vbu/main.ww
Normal file
@@ -0,0 +1,12 @@
|
||||
// #30 VALUE-BEFORE-USE — the twin of ../modfn_coexist/main.ww with the
|
||||
// decl order flipped: `fn aa` is declared BEFORE `import aa`. cstage is
|
||||
// order-independent (installs every SK_USE in a first pass); wwstage
|
||||
// installs in source order, so this direction exercises a DISTINCT path
|
||||
// (installdecl's N_USE arm must set use_alias on the pre-installed value
|
||||
// sym). The gate asserts this builds + runs to 6 AND emits asm
|
||||
// byte-identical to the use-before-value order — silent order-dependence
|
||||
// is exactly what regresses.
|
||||
package main;
|
||||
fn aa() i32 = { return 1; };
|
||||
import aa;
|
||||
export fn main() i32 = { return aa() + aa.helper(); };
|
||||
Reference in New Issue
Block a user