Files
oxc-project__oxc/tasks/coverage/misc/pass/unambiguous-await-call.js
Boshen 91126a01a4 fix(parser): reparse all statements with await identifier in unambiguous mode (#18163)
## Summary

- Fix parsing of `await (...)` and other cases where `await` followed by
certain tokens was parsed as an identifier instead of an await
expression in unambiguous mode
- Commit 92e27b4 only handled `await /regex/` but missed other cases

## Changes

- Add `encountered_await_identifier` flag to `ParserState` to track when
await is parsed as identifier
- Set flag in `parse_identifier_reference` when parsing "await" as
identifier in non-await context
- Modify statement parsing to track checkpoints only for statements that
actually used await as identifier
- Once ESM detected, enable await context for remaining statements

## Test plan

- Added test cases in `tasks/coverage/misc/pass/`:
- `unambiguous-await-call.js` - Tests `await (async function () { })();`
- `unambiguous-await-in-declaration.js` - Tests `const x = await (async
function () { })();`
- All parser tests pass
- All conformance tests pass

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-18 11:18:37 +08:00

3 lines
130 B
JavaScript

// In unambiguous mode with ESM syntax, `await (...)` should parse as await expression
await (async function () { })(); export {}