From dd597102a4e8d308864fd886b41be47761a799fb Mon Sep 17 00:00:00 2001 From: Anders Hejlsberg Date: Wed, 5 Jun 2024 15:43:11 -0700 Subject: [PATCH] Local declarations don't mutate captured outer variables --- src/compiler/binder.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 0b5f5a8f15b..0a9fcdbb464 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1393,7 +1393,7 @@ function createBinder(): (file: SourceFile, options: CompilerOptions) => void { function createFlowMutation(flags: FlowFlags.Assignment | FlowFlags.ArrayMutation, antecedent: FlowNode, node: Expression | VariableDeclaration | ArrayBindingElement) { setFlowNodeReferenced(antecedent); hasFlowEffects = true; - hasFlowMutation = true; + if (node.kind !== SyntaxKind.VariableDeclaration && node.kind !== SyntaxKind.BindingElement) hasFlowMutation = true; const result = createFlowNode(flags, node, antecedent) as FlowAssignment | FlowArrayMutation; if (currentExceptionTarget) { addAntecedent(currentExceptionTarget, result);