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

Do not entirely move else branch if another else branch might accidentally be referenced. #3725

Merged
merged 2 commits into from Aug 15, 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 #3716

Description

In case an if statement is nested within another if statement with no block statement in between and the outer if statement has an else branch, then any else branch of the inner if statement will not be entirely removed to avoid accidentally catching the else branch of the outer if statement.

@rollup-bot
Copy link
Collaborator

rollup-bot commented Aug 14, 2020

Thank you for your contribution! ❤️

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

npm install rollup/rollup#gh-3716

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

@codecov
Copy link

codecov bot commented Aug 14, 2020

Codecov Report

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

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3725   +/-   ##
=======================================
  Coverage   96.97%   96.97%           
=======================================
  Files         184      184           
  Lines        6409     6419   +10     
  Branches     1856     1859    +3     
=======================================
+ Hits         6215     6225   +10     
  Misses        103      103           
  Partials       91       91           
Impacted Files Coverage Δ
src/ast/nodes/IfStatement.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 42d2dfa...07a0771. Read the comment docs.

Copy link
Member

@TrySound TrySound left a comment

Choose a reason for hiding this comment

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

Thanks!

} else throw new Error("Shouldn't be reached");

if (unknown)
for (var x = 1; x--; x > 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not that it matters, but the x > 0 expressions in the 4 loops are superfluous. Perhaps you intended to swap the for loops' test with update.

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense

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.

Else branch follows the wrong if statement
4 participants