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

dead_branch_remover removes PURE annotations on sequence expressions #8907

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

devongovett
Copy link
Contributor

In code like /*#__PURE__*/ (0, forwardRef)(Foo);, the dead_branch_remover pass will simplify this to forwardRef(Foo) and remove the PURE annotation which might be used in later passes. I added a test to show this, and commented out the line that causes it. However I'm not quite sure how to fix it.

I guess the comment is attached to the original sequence expression which was removed. So we need to move the comment to the resulting expression somehow, or maybe change the span of the expression to match the old one.

I tried passing in the comments to this pass so I could move it, but it was a bit hard because of the Parallel implementation that would require the comments to be Send + Sync.

Any suggestions on the best approach here?

Copy link

changeset-bot bot commented May 1, 2024

⚠️ No Changeset found

Latest commit: 9f9f1ea

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

// TODO: preserve PURE comment attached to original
// sequence expression.

// *e = *s.exprs.pop().unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

You can

  1. assign the span of the node with PURE comment to the emitted node

  2. Accept C: Comments or &dyn Comments and call move_leading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants