Commit Graph

984 Commits

Author SHA1 Message Date
4377634bb9 ww: preserve command package identities 2026-08-13 03:37:08 +09:00
cc6799c3b1 test: prove canonical directory package identity 2026-08-13 02:48:17 +09:00
853090174b test: follow canonical directory root artifacts 2026-08-13 00:59:59 +09:00
27a501fc31 test: prove command-global package action reuse 2026-08-13 00:54:12 +09:00
2dd6b8a250 build: close package variant identity gaps 2026-08-12 22:09:55 +09:00
1724ea086f build: make executable and test roots package actions 2026-08-12 22:00:02 +09:00
fc4bde703e compiler: separate package exports from entry roots 2026-08-12 21:59:51 +09:00
edd3f4ee83 build: pass direct exports to package compilers 2026-08-12 18:42:22 +09:00
b373c445bd test: resolve byte-id fixtures as directory packages 2026-08-12 17:26:06 +09:00
3e7d2581cc test: cover directory-only import resolution
Exercise both real drivers with an earlier single-file decoy and a later canonical package directory, exact sorted unit ownership, direct export composition, deterministic package artifacts, transitive linking, stable file-only rejection, and a directory-package test import.
2026-08-12 17:13:07 +09:00
c7d9dc92de selfhost: migrate tool sources to directory packages
Build w6a and w6l from package-main directories and expose the wcc backend through a narrow package API so w6c and wwdump no longer import implementation files. Retarget the remaining load-bearing fixtures and example sources to directory packages; retain the one intentional flat compiler collision as an explicitly composed raw unit.
2026-08-12 17:12:03 +09:00
badde25fa9 test: cover driver-aware warm package reuse 2026-08-12 15:51:50 +09:00
470aacef95 test: cover package and runtime library roots 2026-08-12 15:18:51 +09:00
bb71b31f81 test: cover exact package tool invocation paths 2026-08-12 14:29:17 +09:00
f709a2c440 test: cover shared multi-directory package builds 2026-08-12 13:54:22 +09:00
02574c88f1 test: cover shared directory test build plans 2026-08-12 11:42:29 +09:00
7d25ad9f9f test: cover directory package test graphs 2026-08-12 03:46:58 +09:00
0ac0fd68ec cmd: compile packages from direct exports 2026-08-12 01:12:50 +09:00
9b970eb16a compiler: make package exports self-contained 2026-08-12 01:12:42 +09:00
52f6d6f0d4 cmd: build local package graphs 2026-08-11 22:26:07 +09:00
db96422f74 compiler: load imports and enforce package exports 2026-08-11 22:25:59 +09:00
a04de3e02b bufio: make scanning bounded and incremental 2026-08-09 18:17:42 +09:00
134f0ceef0 test: delete unconsumed legacy inputs 2026-08-09 12:07:13 +09:00
a2faa8b071 w6c: keep nested unwrap destinations distinct 2026-08-09 04:52:43 +09:00
ac8ddee6c1 w6l: purge dead elf branches; pin rx extent 2026-08-09 04:37:33 +09:00
a85306e68f wwdump: fail ast mode on parser errors 2026-08-09 04:02:11 +09:00
00d0ed502d ww: resolve root argv0 and retire stale help paths 2026-08-09 03:56:37 +09:00
edacb40bfe w6c: keep unwrap destination off the call stack 2026-08-09 03:44:12 +09:00
a030268c52 wcc: build generated labels at their exact size 2026-08-09 03:38:03 +09:00
0a16811ab1 w6c: preserve grouped and qualified types in wwi 2026-08-09 03:31:40 +09:00
53a9e94736 wcc: reject final-band integer overflow; restore rewind columns 2026-08-09 03:25:17 +09:00
999b110001 wcc: forrange bindings get a per-loop scope; dup binders reject
The TODO(#11) silent-accept of `for (let (a, a) .. xs)` rested on a
stale premise -- resolvewalk has per-block scopes since #53 and IS
the live w6c_ww checker pass. Bindings now install in a per-LOOP
scope (the N_MCASE pattern), so a duplicate name within one pattern
errs "redeclared in same scope" (cstage parity via stamptuplebinds'
scopedefine-nil check) while sequential same-name loops stay legal.
kwtab restores its stated alphabetical order (`import` before `is`,
both stages, kinds swapped in lockstep with names).
2026-08-09 01:59:33 +09:00
411515a83b wcc: checker-seam drain — spreads, tuple aliases, yield scoping
Four seams from one review cluster, all landing on the same checker
files; gates ran on the union (rule 11 body).

?-subset: the wwstage walk compared `...spread` ALIAS nodes on both
sides of the error-subset check, falsely rejecting a spread-carried
error return (`(i64 | ...errs)`, cs-accept/ww-reject) — both sides
now flatten like trycountvariants (cstage Tparams are pre-flattened
at type level).

Multi-let/multi-assign: the tuple gates keyed on the RAW rhs kind,
rejecting a NAMED tuple alias (`type pair = (i64,i64)`; cs clean-
reject, ww asserttyped stop) — both stages chase per #99 alias
transparency, wwstage rettupleof peels the alias so cgmassign keeps
the str element's len/cap stores, and the catA massign-alias error
pin re-rules to a run fixture. The N_MLET diagnostic also printed
its operands swapped (elem/declared reversed vs its wording).

Yield: match_yield_type didn't descend into N_SWITCH, so a yield
inside a switch arm typed the match void and dropped the value
(both stages); and a stray yield outside any match arm reached cgen
unchecked — both stages now gate on a match-arm counter (the
c->loops discipline).
2026-08-09 01:51:39 +09:00
503d1ab01e wcc: wwstage checks call arity at desugarcallargs
cstage rejects `add(1,2,3)` and `add(4)` (too many / not enough
arguments); wwstage ran no count check at this seam, so both built
-- a stray arg pushed silently, a missing one read garbage
(cs-reject/ww-accept build-verdict divergence). Surplus errs when
params exhaust with args left; missing errs on a leftover regular
param (a leftover TK_ELLIPSIS or FFI "..." is a legal zero-arg
variadic tail). fn-VALUE callees still bail at decl==nil -- their
whole typecheck, arity included, stays task #51.
2026-08-09 01:33:14 +09:00
cf9d83b209 wcc: enums compare nominally; folded members keep their enum stamp
Two composing defects made a two-enum union mis-tag in wwstage
(live cs!=ww: `let e: (color|shape) = shape.BALL` stored tag 0 —
the color arm — while cstage stored 1). type_eq/typeeq had no
TY_ENUM arm, so ANY two enums fell into the primitive default and
compared equal; enums are nominal (harec: an enum IS its alias
type) and now compare by node identity only. Underneath, the
wwstage post-order revisit re-stamped the constant-folded enum
member (an N_INTLIT) as untyped_int, clobbering the enum stamp the
N_DOT fold applied, so the widen matcher fell to its first-variant
fallback -- the #59.9 N_BIN guard now twins on N_INTLIT (cstage
cexpr is single-pass and never clobbered).
2026-08-09 01:26:31 +09:00
f06c95e66b w6c: forrange bind cap loud; drain widen gates keyed on type-eq (#55)
Two silent seams in one sweep. The for-range destructure silently
dropped the 9th+ binding in both stages (bind arrays are sized 8);
the cap now hard-stops per the DEFER_MAX/LOOP_MAX discipline (the
shape is unreachable today -- every wide-tuple construction path
already loud-stops). argtaggedwidensz, the drain-side SSoT for
widened call args, still keyed "natural push" on slot-size equality
while pushargsrev flipped to type equality with #55 -- a same-slot
subset was classified widen by push, natural by drain (counts
coincide today; a classification reader desyncs, the #48 shape).
Both sides now share the wsame key; the widen-branch tag miss for a
concrete source joins the task-2 loud-stop family (tagged subset
sources keep t=0 -- their widentag is never read, the scratch store
remaps).

Lead 17 (enum fold-failure prev+1) DISPROVED: enumvalfold gates
every member init in the checker and its fold set is op-for-op
equal to cgen's enumevalmember, so the fallback only runs inside
already-failing compiles.
2026-08-09 00:52:27 +09:00
973dd964c9 wcc: structlit repeat-fill dim off the stamped tinfo (rule 13)
cgstructlitfill's `...` total read only an N_INTLIT dim node, so a
def-dimensioned [N]T struct field under-filled: elements 1..N-1 kept
the zero-fill, silently, wwstage only (cstage and the tn twin read
the stamped array length). Read tichase(fi.tnode.type_).alen first;
the surface node stays as the fallback for unstamped shapes.
2026-08-09 00:40:23 +09:00
f191e6e0e2 wcc: modulo is integer-only; compound ops carry their operand class
Hare's rule (harec check.c binarithm): % and the bitwise/shift five
are integer-only; + - * / need numeric operands. ww grouped % with
the numeric ops, and compound assigns never op-checked at all, so
`a % b` on floats compiled half-lowered (live cs!=ww divergence),
`a %= 2.0` plain-stored the rhs (op silently dropped, both stages),
and `s += "cd"` garbled str headers. Gate both at the checker, both
stages; the cgen float-compound fallbacks and the three unknown-
compound legacy defaults (deref/global/local) demote to rule-7 hard
stops. 34 compound-on-tagged/str/slice fixtures re-pin from the old
cgen "not wired" stops to the earlier checker diagnostics; 3 new
reject fixtures pin the closed shapes.
2026-08-09 00:32:41 +09:00
94928470bc w6c: sret-wire the chained-leaf call store (o.a.b = wide())
The chained value-struct walker's N_CALL arm handled only <=24B
register returns; an sret-class rhs fell to the scalar tail and
stored ONE word (the sret dest pointer) into the leaf -- silent
truncation in BOTH stages, byteid-blind. Point the callee's hidden
RDI at the BP-relative leaf slot (the single-dot #234 arm verbatim);
a ptr-root/global chain joins the #234-tail loud-stop family.
2026-08-08 23:51:17 +09:00
83f5956df2 test: banner purge + WHY-only comment sweep (rule 8)
Every section banner dies (103 -> 0) across test/lang, the observer
suites, the C carriers, and the five comment-heavy corpus fixtures;
banner provenance (#N cites, carrier numbers, repair-cluster labels)
folded into headers or adjacent WHY comments. Narration deleted; row
provenance, ref cites, divergence pins, and layout contracts kept
(fwd-ref decl-order guards and bootstrap-gate corpus rationale
restored where the sweep over-cut). Comment-only proven: all 3742
wwbuild workdir .s byte-identical before/after; test-commit and
test-byteid (161 lang + 1399 data, 0 pinned-divergent) green.
2026-08-08 21:40:23 +09:00
659e859f34 ww: test sources are *_test.ww only (Go contract)
Go compiles only _test.go files as tests; discovery now keys on the
_test.ww suffix alone. The line-leading-@test compatibility allowance
(noncanonical filenames admitted as test sources) is removed from both
driver stages and the coordinator. An @test declaration outside a
*_test.ww file is rejected loudly ("@test declaration outside
*_test.ww", wording byte-identical cs/ww) instead of silently running
under compose or silently dropping in a non-T build (#6). Tree audit
found zero real carriers; the two allowance fixtures flip canonical
(dep_test.ww, widget_test.ww). New pins: direnum attest-noncanon
reject row (both-stage stderr parity) and the coordinator
noncanonical_attest_rejected package row.
2026-08-08 20:38:02 +09:00
0cf9643be8 lib: move strconv tests into the package dir (Go layout)
lib/strconv/test/ was the last _test layout deviating from Go's
in-package shape (src/bytes/bytes_test.go declares bytes_test in the
package dir). Its rationale — `import strconv` file-hitting the
sibling strconv.ww — dissolved when #98 made directory packages win
over same-named files on any search entry. libbyteid re-paths the
three fx entries and drops the covered() carve-out: the completeness
scan now keys lib/strconv through the fixtures' dirname. Walk line
flips to "ok lib/strconv [strconv_test, external]".
2026-08-08 20:21:43 +09:00
51cb8e7d64 lib: split strings tests per ref/hare/strings families + helpers file
Unblocked by the package-mode ruling: same-package test files now
compose everywhere (coordinator dir-mode owns test-library and the
libbyteid dir entry owns byte identity), so the per-file standalone
constraint is gone and Go's stdlib layout applies directly. The
15-banner strings_test.ww monolith dissolves into per-ref-file
family files — dup, concat, trim, sub, utf8, iter, tokenize
(tokenize+splitn+cut, all of ref tokenize.ha), pad, replace — plus
helpers_test.ww holding exactly the one cross-family helper (streq),
Go's shared test-helper idiom. Pure moves; family-local helpers
(expect_str_token et al.) stay in their family file. Leading banners
that merely restated the filename dropped; 6 interior sub-family
boundaries remain. lib/ census 141 -> 132.

libbyteid gains the dx() dir-mode entry form decided in B2: compose
every *_test.ww under moddir exactly as pkgcombined does
(module-reset separators, byte-lex order) and byte-id the composed
root through both driver stages. The five per-file strings fx
entries retire into one dx("lib/strings") — every source line they
covered is inside the composed unit, and the completeness scan still
keys the module. NENTEXPECT 60 -> 56.

Recorded, not split: fmt_test's 13 banners are scenario groups over
the one fprint surface and ref/hare/fmt itself keeps a single
+test.ha — a print/wrappers split would fight the ref; memio stays
per the standing ruling (everything ww ports lives in ref
stream.ha).
2026-08-08 19:42:49 +09:00
5a263cb115 test: library behavior owned by the coordinator lib/... walk
Go has no per-file test targets: the PACKAGE is the unit of testing
(`go test ./...`) and same-package test files compose together. The
59-target LIBRARY_TESTS fan-out (per-file -w workdirs, one Make rule
per suite) collapses to one line: `ww test -j $(JOBS) -w
out/wwbuild/wwtest-lib -I lib/ww lib/...` — the regex dir-route
precedent generalized. The lib/regex line and the per-file pattern
rule instance dissolve with it (test/lang keeps its own rule).

Measured before committing (-j4, strings edit row): old per-file
warm 4.7-4.9s; bare walk 5.2-5.6s — a real regression, so the
coordinator first gained the brief's persistent per-package workdir:
`-w DIR` on a package target forwards to wwpackage, which keys
DIR/<dir>_<pkg> per group and hands it to each inner `ww test -c`
build. Reuse stays entirely with the driver's existing
content-identity contract — the coordinator adds pure path policy,
no cache machinery. Both driver stages drop their package-target -w
rejects (forward instead); -w with -c stays rejected at the
coordinator (two ownership contracts). After: 3.9-4.0s on the edit
row, 1.0s warm no-op, 2.5s cold — faster than the old flow on every
row.

package_test's tree -w reject row becomes the positive contract
(cold+warm byte-stable stream, cs/ww same) plus the -c conflict
reject. libbyteid roster shape DECIDED: per-file fx entries stay —
every enrolled file is still standalone-buildable, so coverage is
byte-for-byte unchanged; the dir-mode entry form arrives only with
the B3 shared-helper split that first needs it. Docs: owner table,
target table, -w contract paragraph.
2026-08-08 19:35:50 +09:00
241f28c96b syntax: align for-header grammar to cstage (Go's three forms)
The bbdd8bed residue, ruled by the Go derivation (ww's for IS the Go
for; the cstage grammar is the language definition and already the
Go-shaped one):
- bare `for { }` accepted (align UP to parse.c:1023, incl. for-else);
- 3-clause cond and post each omissible — `for (init;; post)`,
  `for (init; cond)`, `for (init;)` (align UP, parse.c:1092-1097);
- 2-clause `for (cond; post)` REJECTED (align DOWN): the form exists
  in neither Go nor cstage (parse.c:1101 eats a stray ';' then
  requires ')'), so the old wwstage accept was a parser bug. The
  reject wording mirrors cstage's failure mode per stage.

forhdr_{brace,emptymid,partial} run fixtures pin the accepted forms
byte-identically; forhdr_twoclause_reject pins both reject fragments.
Corpus pin 1745/346/21/209/1169/3490.
2026-08-08 19:19:42 +09:00
b52f30a894 wcc: reject module-scope alloc/call let initializers at check time
A module-scope let whose rhs runs code (alloc, call — peeled through
cast/?/! wrappers) emitted no DATAW slot: emit_lets' fold-fail
silently skipped the definition and every reference died at LINK
time with 'undefined reference', the one unacceptable failure mode
(rule 7). Hare's model rejects at check time (ref/harec/src/
check.c:4360 'Unable to evaluate initializer at compile time') and
routes runtime init through @init, which ww does not have — so both
frontends now reject at the declaration with identical wording.

alias_infptr_global flips compile->error as the alloc pin (its
letvartnode N_TPTR-over-N_TSTRUCT coverage lives on in the local
alias_infptr_{nest,slicecap} siblings); callinit_global_reject pins
the call shape. Corpus pin 1741/345/21/209/1166/3482.
2026-08-08 19:15:10 +09:00
84206ff4ed w6c: resolve ptr-to-array and slice-element aggregate sources (task #6 residue)
The two loud siblings filed in d3822d77: (a) an auto-deref *[N]T
indexed base (hs[k].result) failed cgplaceaddr's N_INDEX arm, which
knew only TY_SLICE/TY_ARRAY bases — add the one-pointer hop (the
(*hs)[k] form made implicit; load shape is the slice .ptr word's);
(b) a bare slice-element aggregate source (use(sl[k])) fell off
aggarg_srcaddr's ident-array-only N_INDEX arm into the #271 loud
stop — route the miss through the same cgplaceaddr fallback the
N_DOT arm uses. Both stages, byte-identical (probe matrix: let-copy,
field-assign, call-arg, return, indexed-store all IDENT).

After this, every ADDRESSABLE aggregate source resolves: ident
(local/module-let), deref, dot-chain, and index over array/slice/
ptr-array spines recurse through cgplaceaddr; the remaining loud
paths are rvalue sources (#40 family) and the #274 const-def arg,
both documented divergences. 8 rows added to idxdot_aggcopy_test.
2026-08-08 19:08:19 +09:00
cf69cf2f06 w6c: key tagged natural-push call args on type equality, not slot size
pushargsrev's five aistagged gates (N_IDENT #55, N_CALL #21, N_INDEX
#12, N_DOT #22a, deref #35) treated a tagged arg as already-tagged
when its SLOT SIZE matched the param's. A same-slot subset union
((bool|void) into (i64|bool|void), both 16B) then natural-pushed the
narrower box's words carrying SOURCE tags — no re-layout, no
cg_widen_tag_remap twin — so the callee matched the wrong arm
(silent: probes exited 10/90 where cstage exits 30/27). cstage keys
widen detection on type equality (cgen.c:10000 same = (pu == au) ||
type_eq) and routes every non-same tagged source through the zeroed
scratch + tag remap; the slot-DIFFER wwstage path already mirrored
that byte-identically, so the fix computes cstage's same check once
(wsame) and replaces each slot-size test with it. This also erases
the last known cs!=ww shape divergence (the 16B-local staging vs
direct-push frame delta on prefix subsets).

8 subsetwiden_* fixtures own the class: call-result/ident/str-payload
/mid-arg remap (the wrong-arm shapes), prefix (the shape-divergence
repro), and bigslot/return-pos/struct-24-to-32 sibling guards. Corpus
pin 1740/343/22/209/1166/3480.
2026-08-08 19:01:05 +09:00
dae219b7f6 test: driver_test follows the package-target -o wording
Straggler consumer of the -c -o contract commit; the row's inputs
(-o on a tree target) now take the package-target reject.
2026-08-08 18:12:50 +09:00
53919b3404 lib: split log tests into funcs+global per ref/hare/log
Pure move: log_test.ww dissolves along its banner seams into
funcs_test.ww (the six logger-arg rows — lprintlnbasic/single/empty,
lprintflnbasic/indexed/mods — plus the fatal-family subprocess TODO;
ref/hare/log/funcs.ha owns lprintln/lprintfln and the fatal/lfatal
forms) and global_test.ww (defaultwiredtoglobal, setloggerswap,
printflnglobal; ref/hare/log/global.ha owns default/global/setlogger).
Moved blocks are byte-identical; the 9 banner lines are deleted.
Imports minimized per file (log + memio; the stale fmt/io imports
drop).

Helper inventory: streq spans both halves (all six funcs rows;
setloggerswap + printflnglobal on the global side), so it is
duplicated under per-file names per the sanctioned strconv
streq/fstreq precedent — fstreq in funcs_test.ww (decl + 6 call
sites), gstreq in global_test.ww (decl + 6 call sites); bodies
byte-identical apart from the name. Line-multiset diff old-vs-concat
(heads/banners excluded, names normalized): the only residue is the
9-line streq helper counted twice.

Order-safety, proven on the composed run: dir-mode executes
declaration order per file, files byte-lexicographic (funcs_test <
global_test < silent_test). Observed order: lprintlnbasic,
lprintlnsingle, lprintlnempty, lprintflnbasic, lprintflnindexed,
lprintflnmods, defaultwiredtoglobal, setloggerswap, printflnglobal,
silentwritesnothing, silentignoresprintfln — defaultwiredtoglobal
still precedes every log.setlogger caller (setloggerswap and
printflnglobal, both later in its own file; funcs and silent rows
never call setlogger).

Consumers: Makefile LIBRARY_TESTS replaces the log_test.ww entry with
the two new entries in place; test/byteid/libbyteid_test.ww roster row
becomes two fx rows, NENTEXPECT 59->60.

Validation: standalone ww test lib/log/funcs_test.ww (6 passed) and
lib/log/global_test.ww (3 passed); dir mode ww test lib/log (11
passed, no duplicate symbols); byteid compile-only build exit 0, 60
roster appends == NENTEXPECT.
2026-08-08 18:09:19 +09:00