Skip to content

feat: assignment expr side effect detector#2004

Merged
IWANABETHATGUY merged 7 commits intorolldown:mainfrom
kermanx:feat/assignment-expr-side-effect-detector
Aug 17, 2024
Merged

feat: assignment expr side effect detector#2004
IWANABETHATGUY merged 7 commits intorolldown:mainfrom
kermanx:feat/assignment-expr-side-effect-detector

Conversation

@kermanx
Copy link
Copy Markdown
Contributor

@kermanx kermanx commented Aug 17, 2024

This PR implements the logic for AssignmentExpression in SideEffectDetector. Tests included.

  • Empty destructoring patterns like [] = a, {} = a are considered side-effect-less when a is a local variable. However, it seems that neither Rollup nor Esbuild considered this case.
  • Should expressions like { defineProperty: x } = Object be specially treated? This will introduce lots of complexity, but the usage seems too rare.

@kermanx kermanx changed the title Feat/assignment expr side effect detector feat: assignment expr side effect detector Aug 17, 2024
@netlify
Copy link
Copy Markdown

netlify bot commented Aug 17, 2024

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit 4673f3f
🔍 Latest deploy log https://app.netlify.com/sites/rolldown-rs/deploys/66c0291994c92200088d7817

@magic-akari
Copy link
Copy Markdown
Contributor

There is one case, but I don't think it often occurs in actual coding.

with(obj) {
   [] = x;
}

@kermanx kermanx marked this pull request as draft August 17, 2024 02:50
@kermanx kermanx marked this pull request as ready for review August 17, 2024 02:57
Co-authored-by: IWANABETHATGUY <974153916@qq.com>
auto-merge was automatically disabled August 17, 2024 04:37

Head branch was pushed to by a user without write access

@IWANABETHATGUY IWANABETHATGUY added this pull request to the merge queue Aug 17, 2024
Merged via the queue into rolldown:main with commit dde9b33 Aug 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants