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
Comptime build.w evaluator: ?? on an Option is not evaluable (match is) #1041
Restated 2026-10-25.match on an Option now evaluates in the comptime build evaluator. What is left: ?? on an Option does not, so fs.read_text_opt(p) ?? "" cannot run in build.w.
Original report
Found while landing #953: ToolFs.read_text_opt -> Option[str] is the optional-file probe, and the intended driver spelling is fs.read_text_opt(p) ?? "". Under the pub fn build(ctx: BuildCtx) comptime evaluator (src/ComptimeEval.w) that spelling cannot run — neither ?? nor match on an Option is comptime-evaluable, for any Option, not just the new method. .is_none() / .is_some() / .unwrap() work (eval_option_method_call).
Pre-existing: reproduces with the seed v0.15.1.7-gafab48503 (a plain Vec.pop() Option shows it).
Spec reference: §10.2 (??), §9.7 (pattern matching on Option); §18.5c build.w is ordinary With.
Repro 1 — ?? (with build in a project whose build.w is):
use std.build
pub fn build(ctx: BuildCtx) -> Build:
var v: Vec[i32] = Vec.new()
let x = v.pop() ?? 7
assert(x == 7)
ctx.new_build().executable("app", "src/main.w")
Actual: error: operator requires integer comptime values (the ?? node falls into the integer binary-operator path).
Repro 2 — match on an Option:
use std.build
pub fn build(ctx: BuildCtx) -> Build:
var v: Vec[i32] = Vec.new()
v.push(1)
match v.pop():
Some(x) => assert(x == 1)
None => assert(false)
ctx.new_build().executable("app", "src/main.w")
Actual: error: no comptime match arm matched (subject kind=13 data0=219) — the Some(x) / None arms never match the evaluator's enum value (variant symbol syms.some / syms.none).
Expected: both evaluate as they do natively (the #921 native action runner handles the same code in an ActionCtx action without trouble).
Consequence for #953: build/ probe sites are written as if fs.exists(p): fs.read_text(p) else: "" (dual-valid with the pre-#953 seed); moving them to fs.read_text_opt(p) ?? "" after the reseed needs this fixed first. The cli-selfhost-build-w-tests read-missing fixture uses .is_none() / .unwrap() for the same reason.
changed the title [-]Comptime build.w evaluator: `??` and `match` on an Option are not evaluable (blocks `read_text_opt(p) ?? ""` in build/)[/-][+]Comptime build.w evaluator: ?? on an Option is not evaluable (match is)[/+]on Oct 25, 2026
Fixed on main by 3f96513 (PR #2673, stack #2678; battery green on the stack top 0008bf2). The commit message names the root-cause line and the regression test.
Activity
std.fs: read_file returns Result[str, IoError]; ToolFs.read_text pani…
[-]Comptime build.w evaluator: `??` and `match` on an Option are not evaluable (blocks `read_text_opt(p) ?? ""` in build/)[/-][+]Comptime build.w evaluator: ?? on an Option is not evaluable (match is)[/+]ehartford commentedon Oct 25, 2026
Triage 2026-10-25,
with v0.15.3.0(main a261b65): reproduced for??.pre-release: an ordinary build.w spelling fails with a misleading message; the evaluator already handles the
matchform.test: `??` on an Option evaluates in a build.w (#1041) (#2673)
ehartford commentedon Oct 25, 2026
Fixed on main by 3f96513 (PR #2673, stack #2678; battery green on the stack top 0008bf2). The commit message names the root-cause line and the regression test.