mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-09 08:33:28 +02:00
Fix the static semantics for AssignmentTargetType in both the C++ and
Rust parsers:
- NewExpression is never a valid assignment target. Previously, the C++
parser's is<CallExpression> check matched NewExpression since it
inherits from CallExpression in our AST. Add explicit
!is<NewExpression> guards everywhere.
- CallExpression as assignment target is only valid in non-strict mode
(web-compat "runtime error for function call assignment targets").
Pass strict_mode to is_simple_assignment_target and reject call
expressions in strict mode for assignment, compound assignment,
prefix/postfix update, and for-in/of LHS positions.
- Parenthesized ObjectLiteral/ArrayLiteral (e.g. `({}) = 1`) must not
be treated as destructuring patterns. Track whether the primary
expression was parenthesized and skip binding pattern synthesis.
Update existing tests that were testing incorrect behavior:
- `'use strict'; foo() = 'foo'` is now correctly a SyntaxError
- for-in/of with call expression LHS: use toEval() instead of
toEvalTo() (which runs eval inside a class method, i.e. strict mode)
211 KiB
211 KiB