@@ -676,16 +676,13 @@ namespace ts {
676676 } ;
677677 }
678678
679- function finishFlow ( flow : FlowNode ) : FlowNode {
680- while ( flow . kind === FlowKind . Label ) {
681- const antecedents = ( < FlowLabel > flow ) . antecedents ;
682- if ( ! antecedents ) {
683- return unreachableFlow ;
684- }
685- if ( antecedents . length > 1 ) {
686- break ;
687- }
688- flow = antecedents [ 0 ] ;
679+ function finishFlowLabel ( flow : FlowLabel ) : FlowNode {
680+ const antecedents = flow . antecedents ;
681+ if ( ! antecedents ) {
682+ return unreachableFlow ;
683+ }
684+ if ( antecedents . length === 1 ) {
685+ return antecedents [ 0 ] ;
689686 }
690687 return flow ;
691688 }
@@ -760,10 +757,10 @@ namespace ts {
760757 addAntecedent ( preWhileLabel , currentFlow ) ;
761758 currentFlow = preWhileLabel ;
762759 bindCondition ( node . expression , preBodyLabel , postWhileLabel ) ;
763- currentFlow = finishFlow ( preBodyLabel ) ;
760+ currentFlow = finishFlowLabel ( preBodyLabel ) ;
764761 bindIterativeStatement ( node . statement , postWhileLabel , preWhileLabel ) ;
765762 addAntecedent ( preWhileLabel , currentFlow ) ;
766- currentFlow = finishFlow ( postWhileLabel ) ;
763+ currentFlow = finishFlowLabel ( postWhileLabel ) ;
767764 }
768765
769766 function bindDoStatement ( node : DoStatement ) : void {
@@ -774,9 +771,9 @@ namespace ts {
774771 currentFlow = preDoLabel ;
775772 bindIterativeStatement ( node . statement , postDoLabel , preConditionLabel ) ;
776773 addAntecedent ( preConditionLabel , currentFlow ) ;
777- currentFlow = finishFlow ( preConditionLabel ) ;
774+ currentFlow = finishFlowLabel ( preConditionLabel ) ;
778775 bindCondition ( node . expression , preDoLabel , postDoLabel ) ;
779- currentFlow = finishFlow ( postDoLabel ) ;
776+ currentFlow = finishFlowLabel ( postDoLabel ) ;
780777 }
781778
782779 function bindForStatement ( node : ForStatement ) : void {
@@ -787,11 +784,11 @@ namespace ts {
787784 addAntecedent ( preLoopLabel , currentFlow ) ;
788785 currentFlow = preLoopLabel ;
789786 bindCondition ( node . condition , preBodyLabel , postLoopLabel ) ;
790- currentFlow = finishFlow ( preBodyLabel ) ;
787+ currentFlow = finishFlowLabel ( preBodyLabel ) ;
791788 bindIterativeStatement ( node . statement , postLoopLabel , preLoopLabel ) ;
792789 bind ( node . incrementor ) ;
793790 addAntecedent ( preLoopLabel , currentFlow ) ;
794- currentFlow = finishFlow ( postLoopLabel ) ;
791+ currentFlow = finishFlowLabel ( postLoopLabel ) ;
795792 }
796793
797794 function bindForInOrForOfStatement ( node : ForInStatement | ForOfStatement ) : void {
@@ -807,21 +804,21 @@ namespace ts {
807804 }
808805 bindIterativeStatement ( node . statement , postLoopLabel , preLoopLabel ) ;
809806 addAntecedent ( preLoopLabel , currentFlow ) ;
810- currentFlow = finishFlow ( postLoopLabel ) ;
807+ currentFlow = finishFlowLabel ( postLoopLabel ) ;
811808 }
812809
813810 function bindIfStatement ( node : IfStatement ) : void {
814811 const thenLabel = createFlowLabel ( ) ;
815812 const elseLabel = createFlowLabel ( ) ;
816813 const postIfLabel = createFlowLabel ( ) ;
817814 bindCondition ( node . expression , thenLabel , elseLabel ) ;
818- currentFlow = finishFlow ( thenLabel ) ;
815+ currentFlow = finishFlowLabel ( thenLabel ) ;
819816 bind ( node . thenStatement ) ;
820817 addAntecedent ( postIfLabel , currentFlow ) ;
821- currentFlow = finishFlow ( elseLabel ) ;
818+ currentFlow = finishFlowLabel ( elseLabel ) ;
822819 bind ( node . elseStatement ) ;
823820 addAntecedent ( postIfLabel , currentFlow ) ;
824- currentFlow = finishFlow ( postIfLabel ) ;
821+ currentFlow = finishFlowLabel ( postIfLabel ) ;
825822 }
826823
827824 function bindReturnOrThrow ( node : ReturnStatement | ThrowStatement ) : void {
@@ -880,7 +877,7 @@ namespace ts {
880877 currentFlow = preTryFlow ;
881878 bind ( node . finallyBlock ) ;
882879 }
883- currentFlow = finishFlow ( postFinallyLabel ) ;
880+ currentFlow = finishFlowLabel ( postFinallyLabel ) ;
884881 }
885882
886883 function bindSwitchStatement ( node : SwitchStatement ) : void {
@@ -898,7 +895,7 @@ namespace ts {
898895 }
899896 currentBreakTarget = saveBreakTarget ;
900897 preSwitchCaseFlow = savePreSwitchCaseFlow ;
901- currentFlow = finishFlow ( postSwitchLabel ) ;
898+ currentFlow = finishFlowLabel ( postSwitchLabel ) ;
902899 }
903900
904901 function bindCaseBlock ( node : CaseBlock ) : void {
@@ -913,7 +910,7 @@ namespace ts {
913910 const preCaseLabel = createFlowLabel ( ) ;
914911 addAntecedent ( preCaseLabel , preSwitchCaseFlow ) ;
915912 addAntecedent ( preCaseLabel , currentFlow ) ;
916- currentFlow = finishFlow ( preCaseLabel ) ;
913+ currentFlow = finishFlowLabel ( preCaseLabel ) ;
917914 }
918915 bind ( clause ) ;
919916 if ( currentFlow . kind !== FlowKind . Unreachable && i !== clauses . length - 1 && options . noFallthroughCasesInSwitch ) {
@@ -953,7 +950,7 @@ namespace ts {
953950 file . bindDiagnostics . push ( createDiagnosticForNode ( node . label , Diagnostics . Unused_label ) ) ;
954951 }
955952 addAntecedent ( postStatementLabel , currentFlow ) ;
956- currentFlow = finishFlow ( postStatementLabel ) ;
953+ currentFlow = finishFlowLabel ( postStatementLabel ) ;
957954 }
958955
959956 function bindDestructuringTargetFlow ( node : Expression ) {
@@ -999,7 +996,7 @@ namespace ts {
999996 else {
1000997 bindCondition ( node . left , trueTarget , preRightLabel ) ;
1001998 }
1002- currentFlow = finishFlow ( preRightLabel ) ;
999+ currentFlow = finishFlowLabel ( preRightLabel ) ;
10031000 bind ( node . operatorToken ) ;
10041001 bindCondition ( node . right , trueTarget , falseTarget ) ;
10051002 }
@@ -1024,7 +1021,7 @@ namespace ts {
10241021 if ( isTopLevelLogicalExpression ( node ) ) {
10251022 const postExpressionLabel = createFlowLabel ( ) ;
10261023 bindLogicalExpression ( node , postExpressionLabel , postExpressionLabel ) ;
1027- currentFlow = finishFlow ( postExpressionLabel ) ;
1024+ currentFlow = finishFlowLabel ( postExpressionLabel ) ;
10281025 }
10291026 else {
10301027 bindLogicalExpression ( node , currentTrueTarget , currentFalseTarget ) ;
@@ -1043,13 +1040,13 @@ namespace ts {
10431040 const falseLabel = createFlowLabel ( ) ;
10441041 const postExpressionLabel = createFlowLabel ( ) ;
10451042 bindCondition ( node . condition , trueLabel , falseLabel ) ;
1046- currentFlow = finishFlow ( trueLabel ) ;
1043+ currentFlow = finishFlowLabel ( trueLabel ) ;
10471044 bind ( node . whenTrue ) ;
10481045 addAntecedent ( postExpressionLabel , currentFlow ) ;
1049- currentFlow = finishFlow ( falseLabel ) ;
1046+ currentFlow = finishFlowLabel ( falseLabel ) ;
10501047 bind ( node . whenFalse ) ;
10511048 addAntecedent ( postExpressionLabel , currentFlow ) ;
1052- currentFlow = finishFlow ( postExpressionLabel ) ;
1049+ currentFlow = finishFlowLabel ( postExpressionLabel ) ;
10531050 }
10541051
10551052 function bindInitializedVariableFlow ( node : VariableDeclaration | BindingElement ) {
0 commit comments