Skip to content

await of a void async function waits for it (#440) - #497

Merged
ASDAlexander77 merged 1 commit into
mainfrom
fix-await-void
Oct 4, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
fix-await-void

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

await f() on an async function that returns nothing never ran f before going on, under every memory model, AOT and JIT. The issue's example printed ran 0, and if the program ended first, f never ran at all.

mlirGen(AwaitExpression) wraps the awaited expression in an async.execute and checked the result with EXIT_IF_FAILED_OR_NO_VALUE. A call to a void function succeeds with no value, so the function returned there, before the async.await on the execute's token. The task was never awaited. It now returns early only on a failure (EXIT_IF_FAILED), so a void await waits for its token and gives no value.

New test 00await_void.ts: void awaits of a function, a nested async function, a loop, a method and an arrow function, which must run in order (abc012mg). On main it fails in all 6 ctest variants (compile/JIT, default, rc and none corpus). With the fix it passes in all 6, and under own too.

Gate Result
Windows full suite (Release) 3822/3822
Linux (WSL) full suite 3807/3807
DefaultLib suite, release + debug, compile + JIT gc 159/159; rc, none 158/159 (weakref_basic is gc-only, as on main)
own corpus no flips (460/618; the new test passes under own)

The issue's "Also seen" notes are not part of this change: for await bodies run as concurrent tasks, and a failing assert can hang the JIT after a dropped task.

Closes #440

🤖 Generated with Claude Code

`await f()` on an async function that returns nothing never ran `f`
before going on, under every memory model, AOT and JIT: the await of
the example printed `ran 0`, and `f` did not run at all if the program
ended first. mlirGen(AwaitExpression) wraps the awaited expression in
an async.execute and checked its result with
EXIT_IF_FAILED_OR_NO_VALUE; a call to a void function succeeds with no
value, so it left there, before the async.await on the execute's token.
It now leaves on a failure only, and a void await awaits its token and
gives no value, as it already did with no result slot.

Any await of a void call was affected: a function, a method, an arrow
function, in a loop or in sequence. 00await_void.ts runs them in order
under every model.

Closes #440

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit 27d268d into main Oct 4, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the fix-await-void branch October 4, 2026 21:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

await of a void async function never runs it: the async.execute token is not awaited

1 participant