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:
2026-06-10 14:07:35 +09:00
parent 2227d698c6
commit 49a5173f3f
17 changed files with 358 additions and 22 deletions

View File

@@ -0,0 +1,5 @@
package main;
import bad_deep_pkg;
export fn main() i32 = { return 0; };

View File

@@ -0,0 +1,3 @@
package alpha;
fn aaa() i32 = { return 1; };

View File

@@ -0,0 +1,54 @@
// b.ww — #16 PREP-main peek-edge pin (reviewer-batcha).
// This file's `package beta;` decl sits behind a comment header
// longer than 2048 bytes ON PURPOSE: the old wwstage peekpackage
// capped its read at 2048 bytes and would MISS the package decl
// (return nil), so the strict-same-package dir-enum check would
// skip this file and the alpha/beta mismatch would go undetected
// (build wrongly succeeds). The PREP-peek whole-file read finds
// `package beta;`, so the mismatch fires 'differs from' and the
// build fails — which is what 737's bad_deep family asserts on
// both stages. Do not shorten this header below 2048 bytes.
//
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
// padding line to push the package decl past the 2048-byte peek window.
package beta;
fn bbb() i32 = { return 2; };