Files
ww/test/wcc/944_variant_chain_b95_run.c
Hojun-Cho 246e5bb90e test: migrate Fam9 match/tagged value tests to @test (#5-C5)
fold-2 chunk C5 (drew's Fam8-13 plan), the highest-risk chunk: 21 match/tagged
value-row C drivers re-homed. 20 -> test/lang/*_test.ww @test row-tables + 12
runww //ww:error carriers (both stages reject). The global-tag cluster
(globtag*/globstructwiden/taggedderefstore/...), which sits on the #15/#17
global-ptr fix, was empirically probed byte-id CLEAN -- the predicted hotspot
surfaced ZERO fresh cs!=ww. Carves: variant_chain_b95 #81 -> _runonly (genuinely
diverges at HEAD); callret_bound277 #277 -> slim C pin (cs-runs/ww-rejects),
mutation-gated. 929_tagged_memarg kept whole (SSE-ABI asm conformance). 19
drivers deleted, 944_variant_chain slimmed to the #277 pin.

The match-on-tagged-struct-field divergence (former #26) probed RESOLVED for all
its cited shapes (938 voidstr_field/recursion_torture, tagnorm dedup_match all
byte-id cs==ww + value-correct) -- closed no-reproducer-at-HEAD, attribution to
#15/#17 INFERRED. Those rows migrate as normal byte-id @test and serve as the
REGRESSION SENTINEL for the inferred close (a resurgence trips the gate).

LANGBYTEID floor 93->113; test count 374->355 (19 deleted; 929 + 944_variant_chain
kept). do-not-auto-batch (926_tagscr/940_global_sret/940_str_forrange) untouched.
2026-06-24 20:42:08 +09:00

144 lines
4.4 KiB
C

/*
* 944_variant_chain_b95_run -- SLIMMED to the one irreducible asymmetric row.
*
* The #95 variant-match chain-membership corpus (22 rows) migrated to fold-2
* homes (#5-C5): the K_RUN value rows -> test/lang/variant_chain_b95_test.ww
* (@test + T2 byte-id); the two #81-byte-id-waived CALL-source rows ->
* test/lang/variant_chain_b95_runonly_test.ww (value-only); the K_BUILDERR
* reject rows -> test/wcc/data/vchain_<name>/case.ww runww //ww:error carriers.
*
* callret_bound277 (kb5_v2sE) CANNOT move: it is cstage-runs / wwstage-rejects
* -- cstage builds+runs it (exit 0) while wwstage LOUD-STOPS with "deferred
* #277" (the ww aggregate-return capability gap, OUT of #95). That asymmetry is
* inexpressible as a single-compile @test (which builds one way) or a runww
* //ww:error carrier (which demands BOTH stages reject). It stays a slim C pin.
*
* Non-vacuity (the pin CAN go RED): if cstage stops running it (exit != 0) or
* wwstage starts accepting it (#277 wired), the row fails; the wwstage leg also
* requires the EXACT "deferred #277" diagnostic so an unrelated wwstage error
* cannot masquerade as coverage. Mutation-checked: dropping the cast-to-alias
* (`mk()` typed plainly) flips cstage and was observed RED.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/wait.h>
static int
runwait(const char *cmd)
{
int rc = system(cmd);
if (rc == -1) return -1;
if (WIFEXITED(rc)) return WEXITSTATUS(rc);
return -1;
}
static int
errlog_has(const char *path, const char *needle)
{
FILE *f = fopen(path, "rb");
if (!f) return 0;
char buf[8192];
size_t got = fread(buf, 1, sizeof buf - 1, f);
fclose(f);
buf[got] = '\0';
return strstr(buf, needle) != NULL;
}
/* kb5_v2sE: a CALL whose result is typed as the alias ali, widened into
* (void | ali). cstage's aggregate-return path runs it; wwstage #277 rejects. */
static const char *src =
"package main;\n"
"type base = struct { a: int, b: int };\n"
"type al0 = base;\n"
"type ali = al0;\n"
"fn mk() ali = {\n"
" let s: ali;\n"
" s.a = 4; s.b = 9;\n"
" return s;\n"
"};\n"
"export fn main() i32 = {\n"
" let v: (void | ali) = mk();\n"
" if (!(v is ali)) { return 1; };\n"
" return 0;\n"
"};\n";
static const char *experr = "deferred #277";
/* Build src with `driver`; if expect_err, the build must FAIL with experr on
* stderr. Otherwise build must succeed, then the binary runs and its exit must
* equal `want`. Returns 0 on the expected outcome, 1 otherwise. */
static int
check(const char *driver, int expect_err, int want)
{
char tmpdir[96], srcp[128], outbin[128], errf[128], rmcmd[160], cmd[1024];
snprintf(tmpdir, sizeof tmpdir, "/tmp/vc277_%d_%d", getpid(), expect_err);
mkdir(tmpdir, 0755);
snprintf(srcp, sizeof srcp, "%s/c.ww", tmpdir);
snprintf(outbin, sizeof outbin, "%s/c", tmpdir);
snprintf(errf, sizeof errf, "%s/err", tmpdir);
snprintf(rmcmd, sizeof rmcmd, "rm -rf %s", tmpdir);
FILE *f = fopen(srcp, "wb");
if (!f) { runwait(rmcmd); return 1; }
fputs(src, f);
fclose(f);
snprintf(cmd, sizeof cmd, "timeout 20 %s build -o %s %s >/dev/null 2>%s",
driver, outbin, srcp, errf);
int brc = runwait(cmd);
int rc = 0;
if (expect_err) {
if (brc == 0 || !errlog_has(errf, experr)) {
fprintf(stderr, "callret_bound277: %s expected loud "
"builderr \"%s\" (brc=%d)\n", driver, experr, brc);
rc = 1;
}
} else if (brc != 0) {
fprintf(stderr, "callret_bound277: build via %s failed\n", driver);
rc = 1;
} else {
int got = runwait(outbin);
if (got != want) {
fprintf(stderr, "callret_bound277: %s exit %d, want %d\n",
driver, got, want);
rc = 1;
}
}
runwait(rmcmd);
return rc;
}
int
main(void)
{
const char *bin = getenv("BIN");
if (!bin) bin = "out/bin";
char absbin[2080];
if (bin[0] != '/') {
char cwd[1024];
if (getcwd(cwd, sizeof cwd) == NULL) return 1;
snprintf(absbin, sizeof absbin, "%s/%s", cwd, bin);
bin = absbin;
}
char cdrv[2120], wdrv[2120];
snprintf(cdrv, sizeof cdrv, "%s/ww", bin);
snprintf(wdrv, sizeof wdrv, "%s/ww_ww", bin);
int fail = 0;
fail += check(cdrv, 0, 0); /* cstage runs, exit 0 */
if (access(wdrv, X_OK) == 0)
fail += check(wdrv, 1, 0); /* wwstage loud-stops #277 */
if (fail) {
fprintf(stderr, "variant_chain_b95: %d checks failed\n", fail);
return 1;
}
printf("variant_chain_b95: callret_bound277 pin ok\n");
return 0;
}