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:
@@ -411,6 +411,22 @@ export fn parsefile(p: *parser) *node = {
|
||||
p.curmod = name;
|
||||
continue;
|
||||
};
|
||||
// `//ww:module-reset` — bundle boundary before a package-less
|
||||
// file. Reset curmod to "" so the file's decls (and its own
|
||||
// `import os;`) are attributed to the primary module, not the
|
||||
// preceding bundled package. Codegen-neutral: "" curmod keeps
|
||||
// bare symbols. (#16 option-B; closes task #11.)
|
||||
// Driver-emitted ONLY before package-less files; a hand-placed
|
||||
// directive after a mid-file `package` would strip subsequent
|
||||
// decls to bare — that usage is deliberate-only.
|
||||
if (p.curkind == tkind.TK_MODRESET) {
|
||||
advance(p);
|
||||
let empty: str;
|
||||
empty.ptr = nil;
|
||||
empty.len = 0;
|
||||
p.curmod = empty;
|
||||
continue;
|
||||
};
|
||||
let attrs = parseattrs(p);
|
||||
let exported: i32 = 0;
|
||||
if (p.curkind == tkind.TK_EXPORT) { exported = 1; advance(p); };
|
||||
|
||||
Reference in New Issue
Block a user