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 handling of empty arrays and objects in patterns #1202

Merged
merged 1 commit into from
Apr 30, 2024
Merged

Conversation

edemaine
Copy link
Collaborator

@edemaine edemaine commented Apr 30, 2024

Fix the issue mentioned here: #1200 (comment)

This turned out to be tricky to figure out, as it had to do with the generator! ArrayBindingPattern nodes have a length field which was zero in this case. We could instead remove length fields from AST node objects, but it seems like a useful field name (I'd rather have it defined for ObjectBindingPattern too so that code could be more symmetric), and maybe used a fair amount around array patterns, so changing the generator seemed better. Note that empty arrays are still also removed, using the code down below.

Copy link
Contributor

@STRd6 STRd6 left a comment

Choose a reason for hiding this comment

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

Good catch, thanks!

@edemaine edemaine merged commit 912291f into main Apr 30, 2024
3 checks passed
@edemaine edemaine deleted the pattern-fix2 branch April 30, 2024 14:23
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.

2 participants