fix: ignore hidden named source operands

This commit is contained in:
2026-08-22 19:28:54 +09:00
parent 6279d46652
commit 3922f1c34e
6 changed files with 627 additions and 0 deletions

View File

@@ -8564,6 +8564,40 @@ fn basenameoff(p: *u8, plen: u64) u64 = {
return start;
};
// A named Go source still passes through matchFile's leading-dot/underscore
// exclusion even when UseAllFiles bypasses platform suffixes and build tags.
// Inspect the public operand spelling so a hidden parent is not source identity
// and a hidden symlink spelling cannot be resurrected by a non-directory
// target's name or file kind.
fn sourceoperandignored(path: *u8) bool = {
if (!cstrendswithlit(path, ".ww")) { return false; };
let fi: os.filestat;
match (os.stat(&fi, pathstr(path))) {
case void => {
let typ: u32 = (fi.mode: u32) & 61440u32;
if (typ == os.mode.DIR: u32) { return false; };
};
case let e: os.oserror => return false;
};
let n: u64 = cstrlen(path);
let base: u64 = basenameoff(path, n);
return path[base] == '.' || path[base] == '_';
};
fn sourceoperandnosources(path: *u8) void = {
let n: u64 = cstrlen(path);
let base: u64 = basenameoff(path, n);
cerr("ww: ");
if (base == 0u64) {
cerr(".");
} else { if (base == 1u64) {
cerr("/");
} else {
os.write(os.STDERR_FILENO, path, base - 1u64);
}; };
cerr(": directory contains no WW package sources\n");
};
fn arenadupcstr(src: *u8, plen: u64) *u8 = {
let buf: []u8 = alloc([], plen + 1u64)!;
let i: u64 = 0u64;
@@ -8914,6 +8948,10 @@ fn dobuild(selfdir: *u8, argv: **u8, argc: i32, start: i32) i32 = {
case void => requestedliteral = true;
case let e: os.oserror => void;
};
if (sourceoperandignored(src)) {
sourceoperandnosources(src);
return 1;
};
let isdir: i32 = 0;
let resolved: *u8 = resolvemodule(selfdir, src, incs.ptr, &isdir);
if (resolved == nil) {
@@ -9792,6 +9830,26 @@ fn dotest(selfdir: *u8, argv: **u8, argc: i32, start: i32) i32 = {
producti += 1;
};
};
if (!strings.contains(pathstr(target), "...")
&& sourceoperandignored(target)) {
if (products.len != 0 && outstem != nil) {
cerr("ww test: package-test products reject -o\n");
return 2;
};
if (products.len != 0) {
cerr("ww test: package-test variant needs one directory\n");
return 2;
};
if (packageopts) {
cerr("ww test: package options need a directory\n");
return 2;
};
sourceoperandnosources(target);
if (targetindex >= 0 && compileonly == 0 && emitasm == 0) {
os.write(1, "FAIL\n".ptr, 5u64);
};
return 1;
};
if (patarg != nil) {
let first: os.filestat;
let firstregular: bool = false;