Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(es/compat): Fix optional chaining #7530

Merged
merged 11 commits into from
Jun 19, 2023

Conversation

jridgewell
Copy link
Contributor

@jridgewell jridgewell commented Jun 14, 2023

Description:

This fixes a few bugs with optional chaining:

It also optimizes the AST for runtime evaluation. Before, we constructed a leftwards conditional tree ((_a_b = (_a = a) == null ? void 0 : _a.b) == null ? void 0 : _a_b.c) instead of a rightward tree ((_a = a) == null ? void 0 : (_a_b = _a.b) == null ? void 0 : _a_b.c), which required multiple == null checks after the first nullish is found.

BREAKING CHANGE:

Related issue (if exists):

Fixes #7531

@jridgewell jridgewell changed the title Fix optional chaining that has a call expression Fix optional chaining Jun 14, 2023
@jridgewell jridgewell marked this pull request as draft June 14, 2023 20:26
@jridgewell jridgewell marked this pull request as ready for review June 16, 2023 21:06
@kdy1 kdy1 added this to the Planned milestone Jun 17, 2023
Copy link
Member

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

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

Thank you! Can you fix CI failures?


swc-bump:

  • swc_ecma_transforms_compat

@kdy1 kdy1 changed the title Fix optional chaining fix(es/compat): Jun 19, 2023
@kdy1 kdy1 changed the title fix(es/compat): fix(es/compat): Fix optional chaining Jun 19, 2023
kdy1
kdy1 previously approved these changes Jun 19, 2023
Copy link
Member

@kdy1 kdy1 left a comment

Choose a reason for hiding this comment

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

Thank you so much!

@kdy1 kdy1 enabled auto-merge (squash) June 19, 2023 02:05
Copy link
Collaborator

@swc-bot swc-bot left a comment

Choose a reason for hiding this comment

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

Automated review comment generated by auto-rebase script

@kdy1 kdy1 disabled auto-merge June 19, 2023 02:59
@kdy1 kdy1 merged commit 990e48e into swc-project:main Jun 19, 2023
127 checks passed
@kdy1 kdy1 modified the milestones: Planned, v1.3.65 Jun 19, 2023
@jridgewell jridgewell deleted the jrl-opt-chain-call branch June 20, 2023 18:08
@swc-project swc-project locked as resolved and limited conversation to collaborators Jul 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Optional Chain inside default param expression leaks variable into outer scope
3 participants