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 delete on optional chain #1103

Merged
merged 1 commit into from Nov 13, 2021
Merged

Conversation

jridgewell
Copy link
Collaborator

Fixes #1102

let parent = compressor.parent();
// It's valid to delete a nullish optional chain, but if we optimized
// this to `delete undefined` then it would appear to be a syntax error
// when we try to optimize the delete. Thankfully, `delete 0` is fine.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Great thinking here!

e instanceof AST_Chain ||
is_identifier_atom(e)
)
) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm guessing instanceof AST_Sequence isn't checked here to avoid nested AST_Sequence because the extra one would be compressed right away

@fabiosantoscode
Copy link
Collaborator

Love this, thanks!

@fabiosantoscode fabiosantoscode merged commit 8f30357 into terser:master Nov 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

missing delete in output
2 participants