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

Handle hoisted variables in dead branches of nested if statements #3782

Merged
merged 2 commits into from Sep 16, 2020

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:
Resolves #3780

Description

This will wrap the hoisted variables together with the if statement in a block statement unless the parent is either itself a block statement or the module. This will fix wrong branch associations and other issues as described in #3780.

@rollup-bot
Copy link
Collaborator

rollup-bot commented Sep 16, 2020

Thank you for your contribution! ❤️

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

npm install rollup/rollup#gh-3780-chained-if-hoisted-vars

or load it into the REPL:
https://rollupjs.org/repl/?circleci=12927

@codecov
Copy link

codecov bot commented Sep 16, 2020

Codecov Report

Merging #3782 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3782   +/-   ##
=======================================
  Coverage   97.02%   97.03%           
=======================================
  Files         185      185           
  Lines        6460     6465    +5     
  Branches     1870     1874    +4     
=======================================
+ Hits         6268     6273    +5     
  Misses        101      101           
  Partials       91       91           
Impacted Files Coverage Δ
src/ast/nodes/IfStatement.ts 100.00% <100.00%> (ø)
src/utils/options/normalizeInputOptions.ts 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f9b1026...d83229b. Read the comment docs.

@lukastaegert lukastaegert merged commit 1a6cb46 into master Sep 16, 2020
@lukastaegert lukastaegert deleted the gh-3780-chained-if-hoisted-vars branch September 16, 2020 06:18
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.

[BUG] Variables from dead else-if branch are hoisted to incorrect location
2 participants