You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[build] build_graph_dirname("/") returns "" instead of "/" (non-POSIX root) #1021
Severity Low: all in-repo callers (BuildGraphDispatch.w:81,
BuildGraphOps.w:98,136,158, BuildGraphTests.w:24-33,101,174) pass build
output/test paths, for which "/" is unreachable; no spec mandates POSIX
conformance for this internal helper. Filing so the deviation is tracked,
not because it bites today.
Verdict. The central claim is established by running the real functions on current main: build_graph_dirname("/") returns "" and build_graph_path_basename("/") returns "", where POSIX dirname/basename return "/". The defect is wider than the root path: any direct child of root gets an empty dirname (build_graph_dirname("/a") is "", POSIX is "/"). That makes the report's "unreachable in practice" assessment slightly too generous, since a user can spell an output path like -o /prog; see the consequence below. The code is unchanged since the reported revision apart from the byte_at to s[i] sweep.
Tested.
Source
main @ 5809ac1 (2026-09-14); logic identical to 450733e (only c25e844's mechanical byte_at rewrite touched these lines)
Compiler
with v0.15.2.1 built from 5809ac1 in a staging worktree; probe run from that worktree root so use BuildGraphSupport resolves to the tree's own src/
Platform
macOS Darwin 25.6.0 arm64
Probe (with run p.w, rc 0), calling the real functions:
The trailing-slash row is a further POSIX deviation (dirname("/a/") is / and basename("/a/") is a under POSIX, which strips trailing slashes first). It is outside the report's claim and listed only to bound the helper's contract.
Root cause.src/BuildGraphSupport.w:54-67: the loop records the last / index and returns path.slice(0, last_slash); when the only slash is at index 0 the slice is empty. No root special case exists. Established by reading plus the table above; no debugger evidence is needed for a pure string function.
Practical consequence (source-read, not executed). Every action in BuildGraphOps.w computes output_dir = build_graph_dirname(output_path) and then build_graph_rt_mkdir_p(output_dir) (:110-113, :148-151, and six more sites). with_fs_mkdir_p("") ends in mkdir(""), which fails with ENOENT (rt/rt_core.w:3453-3472), so a target whose output lives directly under / would abort with "could not create ... output directory" naming an empty path. I did not run a root-level build to confirm this because it would write outside the scratch area; it follows directly from the two functions above.
Spec. None; build_graph_dirname is an internal helper and the specification does not mandate POSIX semantics for it. The report says the same. The mismatch is still a defect by the repo's own bar: the name promises dirname, callers feed the result to mkdir -p, and the empty result turns a valid path into an error.
Related PRs.#1082 (4815309) added a single absolute-path predicate for POSIX, drive, and UNC roots but did not touch build_graph_dirname; the drive-root case (C:\prog) presumably has the same shape on Windows and was not tested here.
Recommendation. Fix it, small and self-contained: return "/" when the last slash is at index 0 (and treat a drive/UNC root the same way through the #1082 predicate), and strip trailing separators before splitting so basename matches POSIX. Acceptance criteria:
The table above matches the POSIX column for every row.
BuildGraphTests.w gains cases for /, /a, /a/, and a Windows drive root.
A build with -o /<name> (or a temp-mounted equivalent in CI) creates the output instead of failing on an empty directory path.
Triage 2026-10-25, with v0.15.3.0 (main a261b65): reproduced in source. build_graph_dirname (src/BuildGraphSupport.w:64-71) is unchanged: for "/" the last slash is index 0, so it returns path.slice(0, 0), the empty string. The functions are private to the compiler, so no user program can call them directly; the review's run of the real functions stands.
post-release: no current build path passes the root, and the fix is one branch.
Activity
ehartford commentedon Sep 16, 2026
Review: reproduced
Verdict. The central claim is established by running the real functions on current
main:build_graph_dirname("/")returns""andbuild_graph_path_basename("/")returns"", where POSIXdirname/basenamereturn"/". The defect is wider than the root path: any direct child of root gets an empty dirname (build_graph_dirname("/a")is"", POSIX is"/"). That makes the report's "unreachable in practice" assessment slightly too generous, since a user can spell an output path like-o /prog; see the consequence below. The code is unchanged since the reported revision apart from thebyte_attos[i]sweep.Tested.
main@ 5809ac1 (2026-09-14); logic identical to 450733e (only c25e844's mechanicalbyte_atrewrite touched these lines)with v0.15.2.1built from 5809ac1 in a staging worktree; probe run from that worktree root souse BuildGraphSupportresolves to the tree's ownsrc/Probe (
with run p.w, rc 0), calling the real functions:build_graph_dirnamedirnamebuild_graph_path_basenamebasename/""/""//a""/aa/a/b/a/abba/baabba..aa/a//a/""a""..""""The trailing-slash row is a further POSIX deviation (
dirname("/a/")is/andbasename("/a/")isaunder POSIX, which strips trailing slashes first). It is outside the report's claim and listed only to bound the helper's contract.Root cause.
src/BuildGraphSupport.w:54-67: the loop records the last/index and returnspath.slice(0, last_slash); when the only slash is at index 0 the slice is empty. No root special case exists. Established by reading plus the table above; no debugger evidence is needed for a pure string function.Practical consequence (source-read, not executed). Every action in
BuildGraphOps.wcomputesoutput_dir = build_graph_dirname(output_path)and thenbuild_graph_rt_mkdir_p(output_dir)(:110-113,:148-151, and six more sites).with_fs_mkdir_p("")ends inmkdir(""), which fails with ENOENT (rt/rt_core.w:3453-3472), so a target whose output lives directly under/would abort with "could not create ... output directory" naming an empty path. I did not run a root-level build to confirm this because it would write outside the scratch area; it follows directly from the two functions above.Spec. None;
build_graph_dirnameis an internal helper and the specification does not mandate POSIX semantics for it. The report says the same. The mismatch is still a defect by the repo's own bar: the name promisesdirname, callers feed the result tomkdir -p, and the empty result turns a valid path into an error.Related PRs. #1082 (4815309) added a single absolute-path predicate for POSIX, drive, and UNC roots but did not touch
build_graph_dirname; the drive-root case (C:\prog) presumably has the same shape on Windows and was not tested here.Recommendation. Fix it, small and self-contained: return
"/"when the last slash is at index 0 (and treat a drive/UNC root the same way through the #1082 predicate), and strip trailing separators before splitting sobasenamematches POSIX. Acceptance criteria:BuildGraphTests.wgains cases for/,/a,/a/, and a Windows drive root.-o /<name>(or a temp-mounted equivalent in CI) creates the output instead of failing on an empty directory path.ehartford commentedon Oct 25, 2026
Triage 2026-10-25,
with v0.15.3.0(main a261b65): reproduced in source.build_graph_dirname(src/BuildGraphSupport.w:64-71) is unchanged: for"/"the last slash is index 0, so it returnspath.slice(0, 0), the empty string. The functions are private to the compiler, so no user program can call them directly; the review's run of the real functions stands.post-release: no current build path passes the root, and the fix is one branch.
Issues batch A: #1021 #1022 #1023 #2760 #3057 #3060 #3086 #3113 #3114 (…