Skip to content

Commit

Permalink
improve accuracy of static write detection
Browse files Browse the repository at this point in the history
  • Loading branch information
smacke committed Feb 28, 2024
1 parent 41efd0d commit e6c4fba
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core/ipyflow/data_model/scope.py
Expand Up @@ -16,6 +16,8 @@
cast,
)

import pyccolo as pyc

from ipyflow.analysis.live_refs import compute_live_dead_symbol_refs
from ipyflow.analysis.symbol_ref import Atom, SymbolRef
from ipyflow.data_model.symbol import Symbol, SymbolType
Expand Down Expand Up @@ -242,7 +244,10 @@ def _compute_is_static_write(self, sym: Symbol) -> bool:
scope = scope.parent_scope
if not scope.is_global or sym.stmt_node is None:
return False
elif not pyc.is_outer_stmt(id(sym.stmt_node)):
return False
elif isinstance(sym.stmt_node, ast.Assign):
# TODO: must be module level to be a static write
return scope._compute_is_static_write_for_assign(sym)
elif isinstance(
sym.stmt_node, (ast.AsyncFunctionDef, ast.ClassDef, ast.FunctionDef)
Expand Down

0 comments on commit e6c4fba

Please sign in to comment.