Parent: #899
Problem
The parser correctly rejects YieldExpression and AwaitExpression inside generator and async function parameter defaults, but the retained diagnostic is still the internal generic tag:
| source | zig-js | JavaScriptCore 625.1.22 |
|---|---|---|
function* f(a = yield 1) {} | UnexpectedToken | Unexpected keyword 'yield'. Cannot use yield expression within parameters. |
async function f(a = await 1) {} | UnexpectedToken | Cannot use 'await' within a parameter default expression. |
The same prose is used for declarations, expressions, methods, destructuring defaults, and async generators. Nested ordinary functions remain valid because the static Contains query stops at their function boundary.
Arrow cover grammar is intentionally outside this issue: JavaScriptCore diagnoses inherited suspension expressions at the cover-grammar token (=>, or the await operand for a direct async arrow), so those cases need their own reason and source-position treatment.
Implementation shape
- retain the
yieldkeyword offset onyield_expr, asawait_expralready does; - carry function-parameter suspension reasons only while running the existing parameter
Containsscan; - render exact JSC prose without adding work to accepted parameter lists beyond the existing scan;
- cover declarations, expressions, methods, destructuring defaults, async generators, and valid nested-function boundaries.
Verification
- direct JSC differential for the function forms above;
- focused evaluator case with exact
.messagestrings; - standalone parser module;
- exact-parent test262 comparison across generator/async function and parameter subtrees.