Files
ladybird/Libraries/LibJS/Parser.cpp
Andreas Kling c55418bc60 LibJS: Fix AssignmentTargetType for NewExpression and strict mode
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)
2026-03-13 13:08:22 -05:00

211 KiB