In this case, `i` will not created in FunctionScope.
In this case, `i` will not created in FunctionScope.
We don't collect `i` by not calling generic_visit.
We don't collect `i` by not calling generic_visit.
"""
"""
pass
pass
defvisit_DictComp(self,node):
defvisit_DictComp(self,node):
""" the same as ListComp.
"""the same as ListComp."""
"""
pass
pass
defvisit_Name(self,node):
defvisit_Name(self,node):
...
@@ -1212,62 +1280,86 @@ class FunctionNameLivenessAnalysis(gast.NodeVisitor):
...
@@ -1212,62 +1280,86 @@ class FunctionNameLivenessAnalysis(gast.NodeVisitor):
self._current_name_scope().w_vars.add(node.id)
self._current_name_scope().w_vars.add(node.id)
defvisit_FunctionDef(self,node):
defvisit_FunctionDef(self,node):
defpre_func():
defpre_func():
self._current_name_scope().args|=set(
self._current_name_scope().args|=set(
self._get_argument_names(node))
self._get_argument_names(node)
)
defpost_func():
defpost_func():
""" NOTE: why we need merge w_vars and push_pop_vars here ?
"""NOTE: why we need merge w_vars and push_pop_vars here ?
because we do ifelse_transformer after loop_transformer. Loops will changed into functioons. but we know this function will be called in if. so we add w_vars to father function scope.
because we do ifelse_transformer after loop_transformer. Loops will changed into functioons. but we know this function will be called in if. so we add w_vars to father function scope.