Skip to content

Conversation

@liuxingbaoyu
Copy link
Member

Q                       A
Fixed Issues? tc39/test262#4459
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

@babel-bot
Copy link
Collaborator

babel-bot commented Jul 19, 2025

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/59960

Comment on lines 3 to 7
language/expressions/assignmenttargettype/direct-callexpression-in-logical-assignment.js(default)
language/expressions/assignmenttargettype/parenthesized-callexpression-in-logical-assignment.js(default)
language/expressions/logical-assignment/lgcl-and-assignment-operator-non-simple-lhs.js(default)
language/expressions/logical-assignment/lgcl-nullish-assignment-operator-non-simple-lhs.js(default)
language/expressions/logical-assignment/lgcl-or-assignment-operator-non-simple-lhs.js(default)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems impossible to distinguish them with the information available.
I noticed that the engine262 tests at tc39/test262#4459 also fail.
Do we need to ask in test262?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the cases involving the logical assignment operators remain syntax errors.
(See tc39/ecma262#2193 (comment) for the origin story there.)

@liuxingbaoyu liuxingbaoyu marked this pull request as draft July 19, 2025 17:38
@liuxingbaoyu liuxingbaoyu changed the title allow Runtime Errors for Function Call Assignment Targets Allow Runtime Errors for Function Call Assignment Targets Jul 19, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Jul 19, 2025

Open in StackBlitz

commit: 37a0edc

@liuxingbaoyu liuxingbaoyu marked this pull request as ready for review July 28, 2025 20:58
@liuxingbaoyu liuxingbaoyu added PR: Spec Compliance 👓 A type of pull request used for our changelog categories pkg: parser labels Jul 30, 2025
Copy link
Contributor

@JLHwung JLHwung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, left a few comments on tests & docs.

type,
disallowCallExpression ||
(expression.type === "CallExpression" &&
expression.callee.type === "Import"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also exclude Super here, could you also a test for the super() case?

The Import check should be Babel 7 only since we will generate ImportExpression in Babel 8.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It suddenly occurred to me that Babel 8 still supports createImportExpressions as false.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, if that's the case let's keep the import check as-is.

*/
isValidLVal(
type: string,
disallowCallExpression: boolean,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also update the JSDoc comments above?

checkClashes: Set<string> | false = false,
strictModeChanged: boolean = false,
hasParenthesizedAncestor: boolean = false,
disallowCallExpression: boolean = false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pending JSDoc updates.

Comment on lines 10 to 12
async() &&= 1;

import("")++;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these examples are invalid in both annex-B and non-annex-B mode, could you extract these cases to invalid-assignment-target-type? The current one can also be renamed to valid-*.

async()++;
++async();
for (async() in [1]) { }
for (async() of [1]) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add a negative case for parenthesized expressions, such as (f()) = 1. Since the AssignmentTargetType will pass through the parentheses.

async()++;
++async();
for (async() in [1]) { }
for (async() of [1]) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also add a test case for call expression nested within array pattern / object pattern? The AssignmentTargetType does not pass through the array / object pattern, so examples like [f()] = [] should be rejected regardless of the annex B mode.

@liuxingbaoyu
Copy link
Member Author

Thanks for the amazing review!

Copy link
Contributor

@JLHwung JLHwung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new changes look good to me, thank you!

This was referenced Nov 27, 2025
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Dec 19, 2025
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: parser PR: Spec Compliance 👓 A type of pull request used for our changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants