Skip to content

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

Merged
lukastaegert merged 2 commits intomasterfrom
gh-3716
Aug 15, 2020
Merged

Do not entirely move else branch if another else branch might accidentally be referenced.#3725
lukastaegert merged 2 commits intomasterfrom
gh-3716

Conversation

@lukastaegert
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Makes sense

@lukastaegert lukastaegert merged commit 3ff0f81 into master Aug 15, 2020
@lukastaegert lukastaegert deleted the gh-3716 branch August 15, 2020 04:38
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