ww: preserve command package identities

This commit is contained in:
2026-08-13 03:37:08 +09:00
parent 10d24a3237
commit 4377634bb9
10 changed files with 348 additions and 43 deletions

View File

@@ -49,6 +49,9 @@ export type parser = struct {
// Hidden package-driver alias for the toolchain `package test` source.
// Empty outside that one separate-compilation edge.
testmodule: str,
// Selected command-family validation: main/main_test classifies the
// package without replacing the resetmod canonical identity.
commandpackage: bool,
};
fn refill(p: *parser) void = {
@@ -71,6 +74,7 @@ export fn parserinit(p: *parser, l: *lex) void = {
p.pathmod = "";
p.resetmod = "";
p.testmodule = "";
p.commandpackage = false;
refill(p);
};
@@ -619,7 +623,12 @@ export fn parsefile(p: *parser) *node = {
p.testmodule, "__wwtest") == 0
&& strings.compare(active, "__wwtest") == 0
&& strings.compare(name, "test") == 0;
if (strings.compare(name, last) != 0 && !testsupport) {
let commandpackage: bool = p.commandpackage
&& p.pathmod.len == 0 && p.resetmod.len != 0
&& (strings.compare(name, "main") == 0
|| strings.compare(name, "main_test") == 0);
if (strings.compare(name, last) != 0 && !testsupport
&& !commandpackage) {
errmsg(p, "package does not match import path");
};
} else {