Skip to content

Commit 66ff862

Browse files
committed
breaking flows are mutual
1 parent 746b3b7 commit 66ff862

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/compiler.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2826,7 +2826,7 @@ export class Compiler extends DiagnosticEmitter {
28262826
// nest blocks in order
28272827
let currentBlock = module.block(`case0|${context}`, breaks, TypeRef.None);
28282828
let fallThroughFlow: Flow | null = null;
2829-
let commonBreakingFlow: Flow | null = null;
2829+
let mutualBreakingFlow: Flow | null = null;
28302830
for (let i = 0; i < numCases; ++i) {
28312831
let case_ = cases[i];
28322832
let statements = case_.statements;
@@ -2860,21 +2860,21 @@ export class Compiler extends DiagnosticEmitter {
28602860
let possiblyBreaks = innerFlow.isAny(FlowFlags.Breaks | FlowFlags.ConditionallyBreaks);
28612861
innerFlow.unset(FlowFlags.Breaks | FlowFlags.ConditionallyBreaks); // clear
28622862
if (possiblyBreaks || (isLast && possiblyFallsThrough)) {
2863-
if (commonBreakingFlow) commonBreakingFlow.inheritBranch(innerFlow);
2864-
else commonBreakingFlow = innerFlow;
2863+
if (mutualBreakingFlow) mutualBreakingFlow.inheritMutual(mutualBreakingFlow, innerFlow);
2864+
else mutualBreakingFlow = innerFlow;
28652865
}
28662866
this.currentFlow = outerFlow;
28672867
currentBlock = module.block(nextLabel, stmts, TypeRef.None); // must be a labeled block
28682868
}
28692869
outerFlow.popBreakLabel();
28702870

2871-
// If the switch has a default, we only get past through a breaking flow
2871+
// If the switch has a default, we only get past through any breaking flow
28722872
if (defaultIndex >= 0) {
2873-
if (commonBreakingFlow) outerFlow.inherit(commonBreakingFlow);
2873+
if (mutualBreakingFlow) outerFlow.inherit(mutualBreakingFlow);
28742874
else outerFlow.set(FlowFlags.Terminates);
28752875
// Otherwise either skipping or any breaking flow can get past
2876-
} else if (commonBreakingFlow) {
2877-
outerFlow.inheritBranch(commonBreakingFlow);
2876+
} else if (mutualBreakingFlow) {
2877+
outerFlow.inheritBranch(mutualBreakingFlow);
28782878
}
28792879
return currentBlock;
28802880
}

0 commit comments

Comments
 (0)