Skip to content

Commit

Permalink
Fix switch case not being included correctly (#3178)
Browse files Browse the repository at this point in the history
* Fix switch case not being included correctly

* Update dependencies
  • Loading branch information
lukastaegert committed Oct 20, 2019
1 parent 73faf06 commit 06047fc
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/ast/nodes/SwitchStatement.ts
Expand Up @@ -67,7 +67,11 @@ export default class SwitchStatement extends StatementBase {
context.brokenFlow = brokenFlow;
}
}
if (this.defaultCase !== null && !(minBrokenFlow === BROKEN_FLOW_BREAK_CONTINUE)) {
if (
isCaseIncluded &&
this.defaultCase !== null &&
!(minBrokenFlow === BROKEN_FLOW_BREAK_CONTINUE)
) {
context.brokenFlow = minBrokenFlow;
}
}
Expand Down
7 changes: 7 additions & 0 deletions test/form/samples/side-effects-switch-statements/_expected.js
Expand Up @@ -53,3 +53,10 @@ for (var i = 0; i < 4; i++) {
}
effect();
}

var included;
switch (effect()) {
default:
included = 1;
}
console.log(included);
7 changes: 7 additions & 0 deletions test/form/samples/side-effects-switch-statements/main.js
Expand Up @@ -74,3 +74,10 @@ for (var i = 0; i < 4; i++) {
}
effect();
}

var included;
switch (effect()) {
default:
included = 1;
}
console.log(included);

0 comments on commit 06047fc

Please sign in to comment.