Let all early errors be SyntaxErrors
- Category
- JavaScript
- Type
- New or changed feature
- Status
- In development (Chrome In development)
- Intent stage
- Evaluate readiness to ship
WPT details:
Summary
Replace all early ReferenceErrors with early SyntaxErrors.
Motivation
The spec has been inconsistent with respect to the "early ReferenceError" notion: only update/assignment expressions (e.g. `0++`, `0 = 0`) throw early ReferenceErrors, while other invalid assignments like `[0] = []` and `for (0 of []) {}` throw early SyntaxErrors. Furthermore, this becomes an observable concern with eval. If eval throws a ReferenceError, the user has had no way to know whether the code was actually executed or simply parsed (short of matching on error message strings).
Standards & signals
- Specification: https://github.com/tc39/ecma262/pull/1527
- Firefox: No signal
- Safari: No signal
- Web developers: No signals
- Tracking bug: https://bugs.chromium.org/p/v8/issues/detail?id=9326
Ecosystem
- Web Platform Tests: https://wpt.fyi/results/?q=let-all-early-errors-be-syntaxerrors
- Chrome Platform Showcase: https://chrome-platform-showcase.paulkinlan-ea.deno.net/features
- GenDN reference: https://gendn.paulkinlan-ea.deno.net/features
- chrome.dev demos search: https://www.google.com/search?q=site%3Achrome.dev+Let%20all%20early%20errors%20be%20SyntaxErrors
- MDN Web Docs: https://developer.mozilla.org/en-US/search?q=Let%20all%20early%20errors%20be%20SyntaxErrors
- Baseline status: https://webstatus.dev/?q=Let%20all%20early%20errors%20be%20SyntaxErrors
Explainers: https://github.com/tc39/ecma262/pull/1527