/* * 944_alias_cgen_b6_run — SLIM CARRIER (#5-C3 alias fold-2). The 23 K_RUN value * rows migrated to test/lang/alias_cgen_b6_test.ww (@test, cs==ww byte-id); the * symmetric K_BUILDERR rejects (fsarg0_loud_ctl, try_loud_38b) to * test/wcc/data/alias_{fsarg0_loud,try_loud_38b}/case.ww runww. * * What survives here is the one IRREDUCIBLE Group-B row: BOTH stages reject the * same input but with DIFFERENT diagnostics — a held cs!=ww divergence (a * rule-10 smell, tracked not silently merged). A single-substring runww * //ww:error would erase the distinction; this carrier asserts EACH stage's own * substring. cstage rejects with the #271/#165 SSE-eightbyte-transport reason; * wwstage rejects with the #272/#276/#277 aggregate-return scalar-default * reason (the float-bearing alias struct arg from a non-ident source). */ #include #include #include #include #include #include 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; } /* cstage (w6c) rejects with cserr; wwstage (w6c_ww) rejects with wwerr. */ static int run_row(const char *bin, const char *label, const char *src, const char *cserr, const char *wwerr, int i) { char dir[96], srcf[160], cse[160], wwe[160], ss[160], rm[200], cmd[2048]; snprintf(dir, sizeof dir, "/tmp/ab6_%d_%d", getpid(), i); mkdir(dir, 0755); snprintf(srcf, sizeof srcf, "%s/c.ww", dir); snprintf(cse, sizeof cse, "%s/cs.err", dir); snprintf(wwe, sizeof wwe, "%s/ww.err", dir); snprintf(ss, sizeof ss, "%s/o.s", dir); snprintf(rm, sizeof rm, "rm -rf %s", dir); FILE *f = fopen(srcf, "wb"); if (!f) { runwait(rm); return -1; } fputs(src, f); fclose(f); int ok = 1; snprintf(cmd, sizeof cmd, "%s/w6c -o %s %s 2>%s", bin, ss, srcf, cse); int crc = runwait(cmd); if (!(crc != 0 && errlog_has(cse, cserr))) { fprintf(stderr, "row[%s]: cstage expected reject \"%s\" (rc=%d)\n", label, cserr, crc); ok = 0; } snprintf(cmd, sizeof cmd, "%s/w6c_ww -o %s %s 2>%s", bin, ss, srcf, wwe); int wrc = runwait(cmd); if (!(wrc != 0 && errlog_has(wwe, wwerr))) { fprintf(stderr, "row[%s]: wwstage expected reject \"%s\" (rc=%d)\n", label, wwerr, wrc); ok = 0; } runwait(rm); return ok ? 0 : 1; } struct row { const char *label; const char *src; const char *cserr; const char *wwerr; }; static const struct row rows[] = { { "fsarg2_bound", "package main;\n" "type fs0 = struct { x: f64 };\n" "type fs = fs0;\n" "fn mk() fs = {\n" " let s: fs; s.x = 2.5;\n" " return s;\n" "};\n" "fn g(p: fs) f64 = { return p.x; };\n" "export fn main() i32 = {\n" " if (g(mk()) != 2.5) { return 1; };\n" " return 0;\n" "};\n", "#271/#165: float-bearing struct arg from a non-ident source", "#272/#276/#277: aggregate return reaches scalar default" }, }; 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; } int n = (int)(sizeof rows / sizeof rows[0]); int fail = 0; for (int i = 0; i < n; i++) if (run_row(bin, rows[i].label, rows[i].src, rows[i].cserr, rows[i].wwerr, i) != 0) fail++; if (fail) { fprintf(stderr, "alias_cgen_b6 (slim): %d/%d rows failed\n", fail, n); return 1; } printf("alias_cgen_b6 (slim): %d/%d ok\n", n, n); return 0; }