File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
packages/pyright-internal/src Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -1016,11 +1016,18 @@ export class Binder extends ParseTreeWalker {
1016
1016
this . _addAntecedent ( preForLabel , this . _currentFlowNode ! ) ;
1017
1017
this . _currentFlowNode = preForLabel ;
1018
1018
this . _addAntecedent ( preElseLabel , this . _currentFlowNode ) ;
1019
- this . _createAssignmentTargetFlowNodes ( node . targetExpression , /* walkTargets */ true , /* unbound */ false ) ;
1019
+ const targetExpressions = this . _trackCodeFlowExpressions ( ( ) => {
1020
+ this . _createAssignmentTargetFlowNodes ( node . targetExpression , /* walkTargets */ true , /* unbound */ false ) ;
1021
+ } ) ;
1020
1022
1021
1023
this . _bindLoopStatement ( preForLabel , postForLabel , ( ) => {
1022
1024
this . walk ( node . forSuite ) ;
1023
1025
this . _addAntecedent ( preForLabel , this . _currentFlowNode ! ) ;
1026
+
1027
+ // Add any target expressions since they are modified in the loop.
1028
+ targetExpressions . forEach ( ( value ) => {
1029
+ this . _currentScopeCodeFlowExpressions ?. add ( value ) ;
1030
+ } ) ;
1024
1031
} ) ;
1025
1032
1026
1033
this . _currentFlowNode = this . _finishFlowLabel ( preElseLabel ) ;
Original file line number Diff line number Diff line change @@ -86,3 +86,10 @@ def __init__(self):
86
86
87
87
for b in B ():
88
88
...
89
+
90
+ def func3 ():
91
+ x = None
92
+ for x in range (1 ):
93
+ pass
94
+
95
+ reveal_type (x , expected_text = "int | None" )
You can’t perform that action at this time.
0 commit comments