Semantic Diff

#9169 Reject await in a function that an async function returns directly

1 commit

f88294f29a50c4ec4292adea6aefc711e1b199f9..pr-9169

1cb2b80e6 · mununki · Nov 01, 2026, 18:02 UTC

Reject await in a function that an async function returns directly

Why

The built-in PPX let a function in the body of an async function inherit its async context, so await in a plain arrow returned by an async function passed the check, and the JavaScript had await in a function that is not async (#9168). The inheritance comes from the curried parsetree, where async (x, y) => ... was nested functions; in the n-ary parsetree a function in a function's body is a function of its own, so each function is now in an async context exactly when it is async.

addedDiagnostic await in a returned function

let f = async x => y => await y + x
js
Before a SyntaxError when the module loads
async function f(x) {  return y => await y + x | 0;}
diagnostic
After
A.res:1:25-31Await on expression not in an async context

Review

  • Does a working program stop compiling? Only one whose await in such a function was removed by the optimizer, as in an unused definition or a branch under a constant false; the same code in any other plain function is already rejected. Programs that still compile give the same JavaScript, since only the await check reads the async context.