@@ -107,11 +107,11 @@ abstract class PythonSsaSourceVariable extends SsaSourceVariable {
107107
108108}
109109
110-
111110class FunctionLocalVariable extends PythonSsaSourceVariable {
112111
113112 FunctionLocalVariable ( ) {
114- this .( LocalVariable ) .getScope ( ) instanceof Function and not this .( LocalVariable ) .escapes ( )
113+ this .( LocalVariable ) .getScope ( ) instanceof Function and
114+ not this instanceof NonLocalVariable
115115 }
116116
117117 override ControlFlowNode getAnImplicitUse ( ) {
@@ -120,8 +120,14 @@ class FunctionLocalVariable extends PythonSsaSourceVariable {
120120
121121 override ControlFlowNode getScopeEntryDefinition ( ) {
122122 not this .( LocalVariable ) .getId ( ) = "*" and
123- not this .( LocalVariable ) .isParameter ( ) and
124- this .( LocalVariable ) .getScope ( ) .getEntryNode ( ) = result
123+ exists ( Scope s |
124+ s .getEntryNode ( ) = result |
125+ s = this .( LocalVariable ) .getScope ( ) and
126+ not this .( LocalVariable ) .isParameter ( )
127+ or
128+ s != this .( LocalVariable ) .getScope ( ) and
129+ s = this .( LocalVariable ) .getALoad ( ) .getScope ( )
130+ )
125131 }
126132
127133 override CallNode redefinedAtCallSite ( ) { none ( ) }
@@ -131,7 +137,10 @@ class FunctionLocalVariable extends PythonSsaSourceVariable {
131137class NonLocalVariable extends PythonSsaSourceVariable {
132138
133139 NonLocalVariable ( ) {
134- this .( LocalVariable ) .getScope ( ) instanceof Function and this .( LocalVariable ) .escapes ( )
140+ exists ( Function f |
141+ this .( LocalVariable ) .getScope ( ) = f and
142+ this .( LocalVariable ) .getAStore ( ) .getScope ( ) != f
143+ )
135144 }
136145
137146 override ControlFlowNode getAnImplicitUse ( ) {
0 commit comments