Skip to content

fix(annex-b): CallExpression as assignment LHS throws ReferenceError at runtime - #5402

Open
Cypher-CP0 wants to merge 2 commits into
boa-dev:mainfrom
Cypher-CP0:fix/annex-b-call-expression-lhs-5374
Open

fix(annex-b): CallExpression as assignment LHS throws ReferenceError at runtime#5402
Cypher-CP0 wants to merge 2 commits into
boa-dev:mainfrom
Cypher-CP0:fix/annex-b-call-expression-lhs-5374

Conversation

@Cypher-CP0

Copy link
Copy Markdown

This Pull Request fixes #5374.

It changes the following:

  • Adds a Call variant (gated on the annex-b feature) to AssignTarget,
    UpdateTarget, and IterableLoopInitializer in the AST
  • The parser now accepts a CallExpression as LHS in non-strict mode for
    assignments (=, +=, etc.), update expressions (++f(), f()++),
    and for-in/of loops (for (f() in [])) instead of throwing a SyntaxError
  • The bytecompiler evaluates the call for its side effects then emits
    ThrowNewReferenceError without evaluating the RHS, matching the behaviour
    required by Annex B sec-runtime-errors-for-function-call-assignment-targets
  • Updates 3 existing tests that incorrectly expected SyntaxError for these cases

@Cypher-CP0
Cypher-CP0 requested a review from a team as a code owner June 18, 2026 21:16
@github-actions github-actions Bot added the Waiting On Review Waiting on reviews from the maintainers label Jun 18, 2026
@github-actions github-actions Bot added this to the v1.0.0 milestone Jun 18, 2026
@github-actions github-actions Bot added C-Parser Issues surrounding the parser C-Tests Issues and PRs related to the tests. C-VM Issues and PRs related to the Boa Virtual Machine. C-AST Issue surrounding the abstract syntax tree labels Jun 18, 2026
@jedel1043 jedel1043 added Waiting On Author Waiting on PR changes from the author and removed Waiting On Review Waiting on reviews from the maintainers labels Jul 24, 2026
@github-actions

Copy link
Copy Markdown

Test262 conformance changes

Test result main count PR count difference
Total 53,125 53,125 0
Passed 51,073 51,074 +1
Ignored 1,482 1,482 0
Failed 570 569 -1
Panics 0 0 0
Conformance 96.14% 96.14% +0.00%
Fixed tests (6):
test/annexB/language/expressions/assignmenttargettype/callexpression-as-for-in-lhs.js (previously Failed)
test/annexB/language/expressions/assignmenttargettype/callexpression-in-compound-assignment.js (previously Failed)
test/annexB/language/expressions/assignmenttargettype/callexpression-as-for-of-lhs.js (previously Failed)
test/annexB/language/expressions/assignmenttargettype/callexpression.js (previously Failed)
test/annexB/language/expressions/assignmenttargettype/callexpression-in-prefix-update.js (previously Failed)
test/annexB/language/expressions/assignmenttargettype/callexpression-in-postfix-update.js (previously Failed)
Broken tests (5):
test/language/expressions/logical-assignment/lgcl-or-assignment-operator-non-simple-lhs.js (previously Passed)
test/language/expressions/logical-assignment/lgcl-nullish-assignment-operator-non-simple-lhs.js (previously Passed)
test/language/expressions/logical-assignment/lgcl-and-assignment-operator-non-simple-lhs.js (previously Passed)
test/language/expressions/assignmenttargettype/parenthesized-callexpression-in-logical-assignment.js (previously Passed)
test/language/expressions/assignmenttargettype/direct-callexpression-in-logical-assignment.js (previously Passed)

Tested main commit: 5718cc81111ceff12d6054ab948146a45bc6e114
Tested PR commit: 4688e2eac857c7e3441cdc1f44bfbf89fff0604c
Compare commits: 5718cc8...4688e2e

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-AST Issue surrounding the abstract syntax tree C-Parser Issues surrounding the parser C-Tests Issues and PRs related to the tests. C-VM Issues and PRs related to the Boa Virtual Machine. Waiting On Author Waiting on PR changes from the author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Annex B: f() = g() in non-strict mode raises SyntaxError at parse; should be runtime ReferenceError

2 participants