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
await in fn-param defaults checks green but is invisible to the suspend artifact #986
Suspend-boundary bypass, candidate-low (audit finding ASYNC-001). Verified: the language accepts it, the analysis misses it.
Source chain
await in a default-param expression passes with check (probe .audit/probes/readonly_pass_20260903/default_await_probe.w: sync fn f(x: i32 = fetch().await)), while AsyncLower.lower_body walks only the fn-body node (src/AsyncLower.w:90-92) — the suspend is NEVER recorded. Consequences: a sync fn can harbor a suspend; the artifact gating runtime linkage (src/compiler/Compilation.w:1146) may skip linking the fiber runtime for a program whose sole suspend hides in a default (loud link failure expected — reasoned, not executed); with analyze suspend lists are incomplete. (MirSuspendCheck works on MIR bodies so it sees whatever MirLower emits; the hole is AST-walk attribution + flavor gating.)
Repair boundary
Walk default-param expressions in AsyncLower (attributing to caller or callee per the lowering rule) and include them in flavor computation; or reject suspending defaults loudly.
Review: reproduced, and the consequence is worse than "invisible": the awaited value is discarded
Verdict. The report's claims hold on current main: .await inside a default-parameter expression passes with check, and AsyncLower.lower_body walks only the function body node, so the suspend is never attributed anywhere. Running it shows a silent miscompile on top: the default is lowered at the call site (per spec), but the call passes a Unit-typed temporary to the i32 parameter instead of the awaited value, so f() returns whatever happened to be in the argument register (7, 9, 1 in my runs, never 5). --validate-all, --validate-ownership, and with analyze audit:all all report ok on that MIR.
Tested revision and compiler
item
value
source
main @ 5809ac1 (2026-09-14); src/AsyncLower.w unchanged since the reported 450733e except the least-ceremony sweep
compiler
with build of 5809ac1 in a detached worktree, self-reports with v0.15.2.1
--dump-place-map: main:_12 is ty14, the same type id as main's own Unit return local; f:_1 (the parameter) is ty3, the type of fetch's i32 result. So the caller passes a Unit temp to an i32 parameter. In f the MIR is _0 = copy _1, which reads the garbage.
Why it is Unit: in src/MirLower.w:13809-13813 the NK_AWAIT handler takes result_ty = self.expr_type(node) and hands it to lower_single_await. When the await node is reached through lower_default_call_arg from the caller's call lowering (:8939-8960), the recorded expression type for that node is the Unit type rather than i32. I did not trace inside Sema to see whether the default expression's await is type-checked in a mode that does not record the node type or whether the lookup is keyed to the callee's context; that part is a hypothesis. The attribution gap the report names is real and adjacent: src/AsyncLower.w:90-92 walks only fn_body_node, so the suspend inside a default is recorded for neither the declaring function nor the caller.
Tools that stayed silent
validate-all: ok, validate-ownership: ok, and compiler-analysis-audit: ... violations=0 ok on a call whose argument type does not match the callee parameter type. A typed-MIR check of call-argument types against the resolved signature would have caught this in one line; per AGENTS.md that gap should be filed with the fix.
Spec
Spec line 3480: "Default expressions are evaluated at the call site on every call where the argument is omitted." The implementation does evaluate at the call site; it loses the value.
§14 may_suspend (line 6891): a function that "directly performs a primitive current-fiber suspension" is may_suspend, and .await is in the closed primitive set. Whether the suspension in a default belongs to the caller (where it executes) or the callee (where it is written) is exactly the attribution rule the report asks for; the spec does not say, so a ruling is needed. Rejecting suspending defaults outright is the other spec-consistent option.
Related PRs
None since 450733e touch AsyncLower.lower_body, lower_default_call_arg, or the NK_AWAIT lowering. No open PR does.
Would I champion a fix? Yes, and the value bug first.
Acceptance criteria:
The first program prints 5 7; the three-call program prints 5, 9, 5; the async-context program prints 6.
A typed-MIR validator (in validate_mir_body or the analyzer's caller-marshalling audit) rejects a call whose argument operand type differs from the resolved parameter type, and --validate-all reports it on today's MIR.
Ruling recorded in docs/decisions.md: either suspending defaults are attributed to the caller and AsyncLower walks default expressions at each omitted-argument call site, or .await/yield in a default expression is a compile error with a named diagnostic.
Behaviour tests for both spellings (accepted-and-correct, or rejected), plus one for a default in an async fn callee.
Untested
The report's linkage hypothesis (a program whose only suspend hides in a default might skip the fiber runtime link) was not exercised; every probe here also had an async fn, so the runtime was linked regardless. Linux and Windows not executed.
Triage 2026-10-25, with v0.15.3.0 (main a261b65): does not reproduce. An await in a default argument checks, links and runs; defaults are evaluated in the caller (#2024), so the suspend is in the caller's body.
$ cat main.w
async fn fetch() -> i32: 7
fn f(x: i32 = fetch().await) -> i32: x + 1
fn main:
print(f())
$ with check main.w
ok
$ with run main.w
8
Activity
ehartford commentedon Sep 16, 2026
Review: reproduced, and the consequence is worse than "invisible": the awaited value is discarded
Verdict. The report's claims hold on current
main:.awaitinside a default-parameter expression passeswith check, andAsyncLower.lower_bodywalks only the function body node, so the suspend is never attributed anywhere. Running it shows a silent miscompile on top: the default is lowered at the call site (per spec), but the call passes a Unit-typed temporary to thei32parameter instead of the awaited value, sof()returns whatever happened to be in the argument register (7, 9, 1 in my runs, never 5).--validate-all,--validate-ownership, andwith analyze audit:allall report ok on that MIR.Tested revision and compiler
main@ 5809ac1 (2026-09-14);src/AsyncLower.wunchanged since the reported 450733e except the least-ceremony sweepwith buildof 5809ac1 in a detached worktree, self-reportswith v0.15.2.1Probes
with checkwith run7 75 7let a = f(); ... let b = f(9); let c = f()a=9,b=9 c=95,9,5async fn run() -> i32: f() + f(1)awaited from main26fn h(x: i32 = five())and literal defaulth()=5 h(7)=7 k()=5 k(7)=7.awaitin a sync fn body (fn g() -> i32: fetch().await)5So the value loss is specific to
.awaitin the default expression, not to defaults or to awaiting from sync code in general.Root cause (observed in MIR)
--dump-mirof the first program, functionmain:--dump-place-map:main:_12isty14, the same type id asmain's own Unit return local;f:_1(the parameter) isty3, the type offetch'si32result. So the caller passes a Unit temp to ani32parameter. Infthe MIR is_0 = copy _1, which reads the garbage.Why it is Unit: in
src/MirLower.w:13809-13813theNK_AWAIThandler takesresult_ty = self.expr_type(node)and hands it tolower_single_await. When the await node is reached throughlower_default_call_argfrom the caller's call lowering (:8939-8960), the recorded expression type for that node is the Unit type rather thani32. I did not trace inside Sema to see whether the default expression's await is type-checked in a mode that does not record the node type or whether the lookup is keyed to the callee's context; that part is a hypothesis. The attribution gap the report names is real and adjacent:src/AsyncLower.w:90-92walks onlyfn_body_node, so the suspend inside a default is recorded for neither the declaring function nor the caller.Tools that stayed silent
validate-all: ok,validate-ownership: ok, andcompiler-analysis-audit: ... violations=0 okon a call whose argument type does not match the callee parameter type. A typed-MIR check of call-argument types against the resolved signature would have caught this in one line; per AGENTS.md that gap should be filed with the fix.Spec
may_suspend(line 6891): a function that "directly performs a primitive current-fiber suspension" ismay_suspend, and.awaitis in the closed primitive set. Whether the suspension in a default belongs to the caller (where it executes) or the callee (where it is written) is exactly the attribution rule the report asks for; the spec does not say, so a ruling is needed. Rejecting suspending defaults outright is the other spec-consistent option.Related PRs
None since 450733e touch
AsyncLower.lower_body,lower_default_call_arg, or theNK_AWAITlowering. No open PR does.Would I champion a fix? Yes, and the value bug first.
Acceptance criteria:
5 7; the three-call program prints5,9,5; the async-context program prints6.validate_mir_bodyor the analyzer's caller-marshalling audit) rejects a call whose argument operand type differs from the resolved parameter type, and--validate-allreports it on today's MIR.docs/decisions.md: either suspending defaults are attributed to the caller andAsyncLowerwalks default expressions at each omitted-argument call site, or.await/yieldin a default expression is a compile error with a named diagnostic.async fncallee.Untested
The report's linkage hypothesis (a program whose only suspend hides in a default might skip the fiber runtime link) was not exercised; every probe here also had an
async fn, so the runtime was linked regardless. Linux and Windows not executed.ehartford commentedon Oct 25, 2026
Triage 2026-10-25,
with v0.15.3.0(main a261b65): does not reproduce. Anawaitin a default argument checks, links and runs; defaults are evaluated in the caller (#2024), so the suspend is in the caller's body.