wwstage: accept module-level const/let slice-from-arrlit (#28)

wwstage rejected a module-level `const/let []T = [arrlit]` global with "let: not assignable"; cstage accepts (textbook Hare, ref/hare/path/stack.ha:30). The arrlit->slice admission in checkletassign was gated local-only; lift it to module scope too, aligning wwstage UP to cstage's arrlit_init_fits (check.c:3406-3409, slice arm 519-520). cstage unchanged.

Two guards the un-gating requires: the n.rhs.lhs=arr stash stays local-only (a module decl keeps its raw N_ARRLIT for DATA emit, so stashing would leave an untyped count node for the pass-3 asserttyped walker); and tuple-element slice globals are excluded at module scope, because the synthesis delegates element checks to isassignable which lacks a strict tuple arm (#38) -- a [](str,*fn) table would over-accept a sig-mismatched &fn that cstage's strict type_assignable rejects (#124) -- so they stay on the existing typeeqast path.

Closes two divergences 944_alias_emit_b7 pinned: Group A (cstage-runs/ww-rejects) migrates to test/lang/slice_global_arg_test.ww (promoted from _runonly, now cs==ww byte-id); Group B converges to a shared emit_slice_data reject with the identical diagnostic.
This commit is contained in:
2026-06-26 23:16:19 +09:00
parent f476797a47
commit e60297085d
4 changed files with 172 additions and 92 deletions

View File

@@ -4,19 +4,24 @@
* symmetric K_BUILDERR rejects (slcstr_plain_ctl, slcslc_2lvl) to
* test/wcc/data/alias_{slcstr_plain,slcslc}/case.ww runww //ww:error.
*
* What survives here are the 4 IRREDUCIBLE per-stage rows neither in-language
* surface can host (ken's emit_slice_data observation cells — load-bearing
* codegen pins, MUST NOT move):
* • slc_2lvl / slc_plain_ctl (Group A): cstage builds+RUNS exit 0; wwstage
* LOUD-REJECTS at the let checker ("let: not assignable"). cstage emits the
* []my64b / []i64 slice-literal global DATA and runs; the ww checker
* rejects every slice-literal global (the #120/#29-kin acceptance
* divergence, ken-d2-oracle; pre-slim #66-R2/#29). @test needs ww to
* build, //ww:error needs cs to fail — neither fits.
* • slcstr_2lvl / slctag_2lvl (Group B): BOTH reject but with DIFFERENT
* diagnostics (cs at emit_slice_data 3-way "static-init unsupported"; ww at
* the let checker "not assignable") — a held cs!=ww divergence; the two
* messages ARE the pin, so each stage's own substring is asserted.
* What survives here are the 2 IRREDUCIBLE both-stage emit-reject rows neither
* in-language surface can host (ken's emit_slice_data observation cells —
* load-bearing codegen pins, MUST NOT move):
* • slcstr_2lvl / slctag_2lvl: a slice-of-{str,tagged} literal GLOBAL is
* admitted by BOTH checkers and then LOUD-REJECTED at emit_slice_data
* ("slice-of-{str,slice,tagged} literal static-init unsupported", a rule-7
* deferred #10 follow-up) in BOTH stages with the IDENTICAL message. @test
* needs a build, runww //ww:error drives one path — a dual-stage emit
* reject fits neither, so each stage's reject is asserted directly here.
*
* HISTORY (#28): Group A (slc_2lvl []my64b / slc_plain_ctl []i64, cstage-runs /
* wwstage-checker-rejects) and Group B's old wwstage HALF (the ww checker
* rejected EVERY slice-literal global at "let: not assignable") were both that
* pre-#28 divergence. Once the module-scope slice-from-arrlit admission landed
* (selfhost check.ww checkletassign), wwstage admits these globals at the
* checker exactly as cstage does: Group A converged to cs==ww build+run and
* migrated to test/lang/slice_global_arg_test.ww; Group B converged to the
* shared emit_slice_data reject below.
*/
#include <stdio.h>
#include <stdlib.h>
@@ -105,24 +110,6 @@ run_row(const char *bin, const struct row *r, int i)
}
static const struct row rows[] = {
{ "slc_2lvl",
"package main;\n"
"type my64 = i64;\n"
"type my64b = my64;\n"
"let G: []my64b = [5, 6, 7];\n"
"export fn main() i32 = {\n"
" if (G[0] + G[1] + G[2] != 18) { return 1; };\n"
" if (len(G) != 3) { return 2; };\n"
" return 0;\n"
"};\n", M_CSRUN_WWERR, NULL, "let: not assignable" },
{ "slc_plain_ctl",
"package main;\n"
"let G: []i64 = [5, 6, 7];\n"
"export fn main() i32 = {\n"
" if (G[0] + G[1] + G[2] != 18) { return 1; };\n"
" if (len(G) != 3) { return 2; };\n"
" return 0;\n"
"};\n", M_CSRUN_WWERR, NULL, "let: not assignable" },
{ "slcstr_2lvl",
"package main;\n"
"type ms0 = str;\n"
@@ -133,7 +120,7 @@ static const struct row rows[] = {
" return 0;\n"
"};\n", M_BOTHERR,
"slice-of-{str,slice,tagged} literal static-init unsupported",
"let: not assignable" },
"slice-of-{str,slice,tagged} literal static-init unsupported" },
{ "slctag_2lvl",
"package main;\n"
"type u0 = (void | i64);\n"
@@ -144,7 +131,7 @@ static const struct row rows[] = {
" return 0;\n"
"};\n", M_BOTHERR,
"slice-of-{str,slice,tagged} literal static-init unsupported",
"let: not assignable" },
"slice-of-{str,slice,tagged} literal static-init unsupported" },
};
int