lib/ww/parse: error on unknown top-level decl in parsefile fallback (#55)

parsefile's recovery fallback chewed an unrecognized top-level
construct to the next ';' without emitting an error or bumping p.errs,
so a typo'd keyword / stray token silently vanished from the AST and
the build succeeded rc=0 with the declared work gone — no link error
catches a dropped @test or unreferenced exported fn. The C twin
(parse.c:1395-1400) errorf+p->errs++ and rejects. Emit errmsg in the
fallback arm; wwstage now rejects in lockstep with cstage.

lib/ww embeds into the w6c/wwdump combined.ww snapshots; both regen'd.
989_unknowndecl_reject pins the reject-matrix on both driver twins.
This commit is contained in:
2026-06-13 10:33:48 +09:00
parent cf0789c897
commit 5cab22ecec
5 changed files with 231 additions and 0 deletions

View File

@@ -250,6 +250,7 @@ TESTS = $(BIN)/test_smoke $(BIN)/test_lex $(BIN)/test_parse $(BIN)/test_check \
$(BIN)/test_callarg_typecheck \
$(BIN)/test_catA_f2_reject \
$(BIN)/test_intoverflow_reject \
$(BIN)/test_unknowndecl_reject \
$(BIN)/test_idxarg_run \
$(BIN)/test_chainidx_run \
$(BIN)/test_tupfieldsize_run \
@@ -697,6 +698,17 @@ $(BIN)/test_intoverflow_reject: test/wcc/989_intoverflow_reject.c \
$(LIB)/libwwrt.a | $(BIN)
$(CC) $(CFLAGS) -o $@ $<
# 989_unknowndecl_reject (F14 #55): an unrecognized top-level construct
# must FAIL to build on BOTH driver twins (wwstage's parsefile fallback
# silently chewed it with no error). Needs the full cstage + wwstage tool
# sets plus libwwrt for the control links.
$(BIN)/test_unknowndecl_reject: test/wcc/989_unknowndecl_reject.c \
$(BIN)/ww $(BIN)/ww_ww \
$(BIN)/w6c $(BIN)/w6a $(BIN)/w6l \
$(BIN)/w6c_ww $(BIN)/w6a_ww $(BIN)/w6l_ww \
$(LIB)/libwwrt.a | $(BIN)
$(CC) $(CFLAGS) -o $@ $<
# 989_idxarg_run (F7-c2, #45/#46): an indexed slice/str element passed as
# a call arg must push its full multi-word header. Builds+runs each fixture
# on BOTH the cstage `ww` and wwstage `ww_ww` drivers (rule-10), so it needs