@@ -499,8 +499,8 @@ namespace ts {
499499 const saveReturnTarget = currentReturnTarget ;
500500 const saveActiveLabels = activeLabels ;
501501 const saveHasExplicitReturn = hasExplicitReturn ;
502- const isIIFE = containerFlags & ContainerFlags . IsFunctionExpression && ! ! getImmediatelyInvokedFunctionExpression ( node ) ;
503- // An IIFE is considered part of the containing control flow. Return statements behave
502+ const isIIFE = containerFlags & ContainerFlags . IsFunctionExpression && ! hasModifier ( node , ModifierFlags . Async ) && ! ! getImmediatelyInvokedFunctionExpression ( node ) ;
503+ // A non-async IIFE is considered part of the containing control flow. Return statements behave
504504 // similarly to break statements that exit to a label just past the statement body.
505505 if ( isIIFE ) {
506506 currentReturnTarget = createBranchLabel ( ) ;
@@ -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 ) {
@@ -1204,9 +1212,9 @@ namespace ts {
12041212 }
12051213 else {
12061214 forEachChild ( node , bind ) ;
1207- if ( operator === SyntaxKind . EqualsToken && ! isAssignmentTarget ( node ) ) {
1215+ if ( isAssignmentOperator ( operator ) && ! isAssignmentTarget ( node ) ) {
12081216 bindAssignmentTargetFlow ( node . left ) ;
1209- if ( node . left . kind === SyntaxKind . ElementAccessExpression ) {
1217+ if ( operator === SyntaxKind . EqualsToken && node . left . kind === SyntaxKind . ElementAccessExpression ) {
12101218 const elementAccess = < ElementAccessExpression > node . left ;
12111219 if ( isNarrowableOperand ( elementAccess . expression ) ) {
12121220 currentFlow = createFlowArrayMutation ( currentFlow , node ) ;
@@ -3093,6 +3101,8 @@ namespace ts {
30933101 case SyntaxKind . InterfaceDeclaration :
30943102 case SyntaxKind . TypeAliasDeclaration :
30953103 case SyntaxKind . ThisType :
3104+ case SyntaxKind . TypeOperator :
3105+ case SyntaxKind . IndexedAccessType :
30963106 case SyntaxKind . LiteralType :
30973107 // Types and signatures are TypeScript syntax, and exclude all other facts.
30983108 transformFlags = TransformFlags . AssertTypeScript ;
0 commit comments