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 unwrapping of operator sections with placeholders #1685

Merged
merged 1 commit into from
Jan 6, 2025
Merged

Conversation

edemaine
Copy link
Collaborator

@edemaine edemaine commented Jan 6, 2025

Fixes #1682

This is pretty subtle: replaceChild doesn't preserve the aliasing in our grandparent's body. Because of Wrapper nodes in this context, it doesn't work (easily) to put this check into replaceChild. I hope this is the only place we need to do this (where we replace the top level of an ampersand block), but plausibly there are other uses of replaceChild with this issue.

An alternative would be to remove ampersand block's body properties altogether, and just use the block's first expression. Plausibly, we can decide whether to unwrap even without the ampersandBlock hint, checking for a single expression that uses the argument once. Then we could unwrap non-shorthand arrow functions too. Maybe an approach to try in the future.

@edemaine edemaine merged commit 25eb736 into main Jan 6, 2025
4 checks passed
@edemaine edemaine deleted the pipe-section branch January 6, 2025 21:45
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.

1 |> (+ &) generates incorrect JS
2 participants