@@ -448,6 +448,10 @@ def addBinding(self, node, value):
448448 elif isinstance (existing , Importation ) and value .redefines (existing ):
449449 existing .redefined .append (node )
450450
451+ if value .name in self .scope :
452+ # then assume the rebound name is used as a global or within a loop
453+ value .used = self .scope [value .name ].used
454+
451455 self .scope [value .name ] = value
452456
453457 def getNodeHandler (self , node_class ):
@@ -526,8 +530,6 @@ def handleNodeStore(self, node):
526530 binding = ExportBinding (name , node .parent , self .scope )
527531 else :
528532 binding = Assignment (name , node )
529- if name in self .scope :
530- binding .used = self .scope [name ].used
531533 self .addBinding (node , binding )
532534
533535 def handleNodeDelete (self , node ):
@@ -648,8 +650,9 @@ def ignore(self, node):
648650 pass
649651
650652 # "stmt" type nodes
651- DELETE = PRINT = FOR = WHILE = IF = WITH = WITHITEM = RAISE = \
652- TRYFINALLY = ASSERT = EXEC = EXPR = ASSIGN = handleChildren
653+ DELETE = PRINT = FOR = ASYNCFOR = WHILE = IF = WITH = WITHITEM = \
654+ ASYNCWITH = ASYNCWITHITEM = RAISE = TRYFINALLY = ASSERT = EXEC = \
655+ EXPR = ASSIGN = handleChildren
653656
654657 CONTINUE = BREAK = PASS = ignore
655658
@@ -751,7 +754,7 @@ def YIELD(self, node):
751754 self .scope .isGenerator = True
752755 self .handleNode (node .value , node )
753756
754- YIELDFROM = YIELD
757+ AWAIT = YIELDFROM = YIELD
755758
756759 def FUNCTIONDEF (self , node ):
757760 for deco in node .decorator_list :
@@ -761,6 +764,8 @@ def FUNCTIONDEF(self, node):
761764 if self .withDoctest :
762765 self .deferFunction (lambda : self .handleDoctests (node ))
763766
767+ ASYNCFUNCTIONDEF = FUNCTIONDEF
768+
764769 def LAMBDA (self , node ):
765770 args = []
766771 annotations = []
0 commit comments