@@ -892,8 +892,13 @@ namespace ts {
892892
893893 function bindDoStatement ( node : DoStatement ) : void {
894894 const preDoLabel = createLoopLabel ( ) ;
895- const preConditionLabel = createBranchLabel ( ) ;
896- const postDoLabel = createBranchLabel ( ) ;
895+ const enclosingLabeledStatement = node . parent . kind === SyntaxKind . LabeledStatement
896+ ? lastOrUndefined ( activeLabels )
897+ : undefined ;
898+ // if do statement is wrapped in labeled statement then target labels for break/continue with or without
899+ // label should be the same
900+ const preConditionLabel = enclosingLabeledStatement ? enclosingLabeledStatement . continueTarget : createBranchLabel ( ) ;
901+ const postDoLabel = enclosingLabeledStatement ? enclosingLabeledStatement . breakTarget : createBranchLabel ( ) ;
897902 addAntecedent ( preDoLabel , currentFlow ) ;
898903 currentFlow = preDoLabel ;
899904 bindIterativeStatement ( node . statement , postDoLabel , preConditionLabel ) ;
@@ -1111,8 +1116,11 @@ namespace ts {
11111116 if ( ! activeLabel . referenced && ! options . allowUnusedLabels ) {
11121117 file . bindDiagnostics . push ( createDiagnosticForNode ( node . label , Diagnostics . Unused_label ) ) ;
11131118 }
1114- addAntecedent ( postStatementLabel , currentFlow ) ;
1115- currentFlow = finishFlowLabel ( postStatementLabel ) ;
1119+ if ( ! node . statement || node . statement . kind !== SyntaxKind . DoStatement ) {
1120+ // do statement sets current flow inside bindDoStatement
1121+ addAntecedent ( postStatementLabel , currentFlow ) ;
1122+ currentFlow = finishFlowLabel ( postStatementLabel ) ;
1123+ }
11161124 }
11171125
11181126 function bindDestructuringTargetFlow ( node : Expression ) {
0 commit comments