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

Prevent class ids from shadowing other variables #4697

Merged
merged 3 commits into from Nov 1, 2022

Conversation

lukastaegert
Copy link
Member

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

List any relevant issue numbers:

Description

In #4674, we introduced a logic that would rewrite classes to have an id so that in case of name conflicts, they would retain the correct class.name. Unfortunately, this could lead to shadowed variables because the name of this new id was not considered when deconflicting variable names. This is now fixed.

@github-actions
Copy link

github-actions bot commented Oct 31, 2022

Thank you for your contribution! ❤️

You can try out this pull request locally by installing Rollup via

npm install rollup/rollup#gh-4696-class-name-shadow

or load it into the REPL:
https://rollupjs.org/repl/?pr=4697

@codecov
Copy link

codecov bot commented Oct 31, 2022

Codecov Report

Merging #4697 (1a89a4f) into master (ab36666) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #4697   +/-   ##
=======================================
  Coverage   99.02%   99.02%           
=======================================
  Files         215      215           
  Lines        7574     7593   +19     
  Branches     2098     2105    +7     
=======================================
+ Hits         7500     7519   +19     
  Misses         24       24           
  Partials       50       50           
Impacted Files Coverage Δ
src/ast/nodes/ClassDeclaration.ts 100.00% <100.00%> (ø)
src/ast/nodes/VariableDeclarator.ts 100.00% <100.00%> (ø)
src/ast/scopes/ChildScope.ts 100.00% <100.00%> (ø)
src/ast/variables/Variable.ts 100.00% <100.00%> (ø)
src/utils/deconflictChunk.ts 100.00% <100.00%> (ø)
src/utils/safeName.ts 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@lukastaegert lukastaegert merged commit 465d239 into master Nov 1, 2022
@lukastaegert lukastaegert deleted the gh-4696-class-name-shadow branch November 1, 2022 05:27
@rollup-bot
Copy link
Collaborator

This PR has been released as part of rollup@3.2.5. You can test it via npm install rollup.

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.

Import alias reverted in bundled file
2 participants