wcc/cgen: #121 indexed tuple-element read + literal-store round-trip (both-stage)

Reading or storing a tuple element of an indexed array element was
broken across the board (the fold-6 read-path). One fused commit,
both stages, four faces of indexed tuple-element access:

 - FIELD read `tbl[i].N`: was loud ("unsupported field-read shape" --
   the field-read dispatch keyed on an N_IDENT base; an INDEX base fell
   to a fatal). Now resolves &tbl[i] via the place-spine and reads the
   field at addr+foff through the existing per-kind arms (str-triple /
   scalar / fn-ptr).
 - WHOLE read `let e = tbl[i]`: was a silent word0-only truncation
   (plain-tuple kin of #37/#58, which covered only tagged). Now a full
   cursor fill from &tbl[i].
 - STORE `a[i] = (3,4)` (N_TUPLE-literal rhs): was a silent word0-only
   store -- the write face of the read. The aggregate-store-into-index
   site handled ident/dot/deref tuple rhs but not the literal; now it
   materializes the literal and word-copies. Narrow: N_IDENT base only
   (N_DOT/chained stay deferred, #270).
 - for-range over a const-slice-of-tuple: was a divergent SEGV; now a
   symmetric loud-stop on both stages (filed #122).

The store and read were a round-trip that passed test 809 only by luck
(broken store XOR broken read canceled). Fixing the read alone exposed
the silent store; rule-7 obliges fixing both, so 809 is now genuinely
correct, not luck-correct. Both faces are byte-id-blind (#263) -- the
net is a runtime round-trip pin with distinct-per-word values and a
real call clobbering the cursor registers between store and read, so a
word0-only store or read is caught. Both stages byte-identical
(990-997 green). Pin 947_tuple_index_read_run.
This commit is contained in:
2026-06-06 22:23:43 +09:00
parent 761cfa4524
commit 754944a755
8 changed files with 1317 additions and 4 deletions

View File

@@ -1382,9 +1382,11 @@ static const struct row rows[] = {
" return 0;\n"
"};\n", 0,
K_BUILDERR, "tuple arg element kind unsupported" },
/* variadic-of-tuples ((i64,i64)...) stays LOUD via the
* tuple-in-slice read surface — bounded, not silent (demand 2). */
{ "t2_reject_variadic_of_tuples",
/* variadic-of-tuples ((i64,i64)...): `ts[0].0` is an indexed-slice
* tuple-element FIELD read — #121 leg (a) now resolves it (was LOUD
* "unsupported field-read shape"; the dispatch fired only for an
* N_IDENT base). Runs correct both stages + byte-id. */
{ "t2_variadic_of_tuples",
"package main;\n"
"fn first(ts: (i64, i64)...) i64 = {\n"
" if (len(ts) == 0) { return -1; };\n"
@@ -1395,7 +1397,7 @@ static const struct row rows[] = {
" if (first(t) != 3) { return 1; };\n"
" return 0;\n"
"};\n", 0,
K_BUILDERR, "unsupported field-read shape" },
K_RUN, NULL },
/* rule-7: a tuple arg from a source whose cgexpr does NOT fill
* the cursor (here a struct-field chain) dies loud — pre-C-t2
* it fell to the scalar single-PUSHQ default silently.