wcc/ww: compound OP= on a tagged index/ident is a loud reject (#20/#21)

Compound `OP=` through an index (gs[i]/a[i]) or a bare ident (g) on a
tagged union silently misbehaved: cstage dropped the index compound and
plain-stored, and BOTH stages compiled an ident compound into an add on
the tag word -- byte-identical, so the gate stayed green while the tag
was corrupted. A compound op on a whole union is nonsense.

Gate the index plain-store arm on TK_ASSIGN so a compound falls to the
existing #133 reject (wwstage's byte-id twin); add a dedicated #21 ident
reject in both stages. This closes the compound half of the tagged-payload
write class (deref #18, dot #34 already reject).

#19 (global tagged-array static-init DATA) is a separate emitter, still open.
This commit is contained in:
2026-06-14 01:14:51 +09:00
parent 769be55905
commit 33f940e17c
6 changed files with 427 additions and 2 deletions

View File

@@ -254,6 +254,7 @@ TESTS = $(BIN)/test_smoke $(BIN)/test_lex $(BIN)/test_parse $(BIN)/test_check \
$(BIN)/test_unknowndecl_reject \
$(BIN)/test_nullableglobal_reject \
$(BIN)/test_taggedcompoundderef_reject \
$(BIN)/test_taggedcompoundplace_reject \
$(BIN)/test_idxarg_run \
$(BIN)/test_chainidx_run \
$(BIN)/test_tupfieldsize_run \
@@ -754,6 +755,24 @@ $(BIN)/test_taggedcompoundderef_reject: test/wcc/989_taggedcompoundderef_reject.
$(LIB)/libwwrt.a | $(BIN)
$(CC) $(CFLAGS) -o $@ $<
# 989_taggedcompoundplace_reject (#20/#21, last two members of the
# compound-OP-on-tagged-place reject class): `gs[i] OP= v` / `a[i] OP= v`
# (INDEX, #20) and `g OP= v` (IDENT, #21) on a tagged-union place are
# nonsense and must loud-reject. cstage silently dropped the indexed compound
# (cs!=ww); BOTH stages silently corrupted the tag word for the ident
# compound (byte-id-green). The fix gates the cstage indexed plain-store arm
# on TK_ASSIGN (compound falls to the #133 reject) and adds a tagged-ident
# compound guard to both stages. Reject rows assert build-fail + the
# per-place-kind diagnostic (#133 for index, #21 for ident); control rows
# (scalar ident/index compound + plain tagged ident/local-index/global-index
# store) build + run. Needs both tool sets + libwwrt for the control links.
$(BIN)/test_taggedcompoundplace_reject: test/wcc/989_taggedcompoundplace_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