wcc+ww: //ww:module-reset boundary directive; package-less files keep module "" (#16 PREP-main)
Driver twins emit the line-comment directive only before package-less files (peekpackage==nil); both lexers tokenize it (TK_MODRESET, appended =87 so existing token values hold) and both parsers reset curmod — a package-less file's decls get module "" instead of inheriting the last bundled package (the sticky-curmod leak, task #11). Withdrawn alternative: injecting 'package main' flips non-entry symbols bare->main-prefixed (FFI-visible, broke 764). Codegen-neutral by proof: bare symbols preserved, both stages emit byte-identical asm for a directive-bearing combined. Transitional until strict-package rejects package-less files outright. Includes 737 bad-deep pin for the PREP-peek >2048 edge + 904/toktest rows for the new token.
This commit is contained in:
@@ -133,6 +133,46 @@ main(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* bad-deep: same mismatch, but one file's `package` decl sits behind
|
||||
* a >2048-byte comment header. Pins the PREP-peek whole-file read
|
||||
* (#16): the old 2048-capped peek missed that decl, so the strict-
|
||||
* same-package check skipped the file and the mismatch went
|
||||
* undetected (build wrongly succeeded); the whole-file peek finds it
|
||||
* → "differs from". Both stages. (reviewer-batcha pin.) */
|
||||
{
|
||||
const char *src = "test/wcc/data/direnum/bad_deep_entry.ww";
|
||||
snprintf(errp, sizeof errp, "/tmp/direnum_%d_baddeep.err", getpid());
|
||||
|
||||
char cmd[2048];
|
||||
snprintf(cmd, sizeof cmd, "%s build %s 2>%s >/dev/null",
|
||||
ww, src, errp);
|
||||
int rc = runwait(cmd);
|
||||
total++;
|
||||
if (rc == 0) {
|
||||
fprintf(stderr, "737[bad-deep-cstage]: expected build failure, succeeded\n");
|
||||
fail++;
|
||||
} else if (!stderr_contains(errp, "differs from")) {
|
||||
fprintf(stderr, "737[bad-deep-cstage]: stderr missing 'differs from'\n");
|
||||
fail++;
|
||||
}
|
||||
unlink(errp);
|
||||
|
||||
if (access(ww_ww, X_OK) == 0) {
|
||||
snprintf(cmd, sizeof cmd, "%s build %s 2>%s >/dev/null",
|
||||
ww_ww, src, errp);
|
||||
rc = runwait(cmd);
|
||||
total++;
|
||||
if (rc == 0) {
|
||||
fprintf(stderr, "737[bad-deep-wwstage]: expected build failure, succeeded\n");
|
||||
fail++;
|
||||
} else if (!stderr_contains(errp, "differs from")) {
|
||||
fprintf(stderr, "737[bad-deep-wwstage]: stderr missing 'differs from'\n");
|
||||
fail++;
|
||||
}
|
||||
unlink(errp);
|
||||
}
|
||||
}
|
||||
|
||||
if (fail) {
|
||||
fprintf(stderr, "737_direnum: %d/%d fixtures failed\n", fail, total);
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user