File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed
python/ql/lib/semmle/python/dataflow/new/internal Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -417,18 +417,18 @@ module VariableCapture {
417
417
Function f ;
418
418
419
419
CapturedVariable ( ) {
420
- // exists(this.getScopeEntryDefinition())
421
420
this .getScope ( ) = f and
422
- (
423
- this .getALoad ( ) .getScope ( ) != f
424
- or
425
- this .getAStore ( ) .getScope ( ) != f
426
- )
421
+ this .getAnAccess ( ) .getScope ( ) != f
427
422
}
428
423
429
424
Callable getCallable ( ) { result = f }
430
425
431
426
Location getLocation ( ) { result = f .getLocation ( ) }
427
+
428
+ Scope getACapturingScope ( ) {
429
+ result = this .getAnAccess ( ) .getScope ( ) .getScope * ( ) and
430
+ result .getScope + ( ) = f
431
+ }
432
432
}
433
433
434
434
class CapturedParameter extends CapturedVariable {
Original file line number Diff line number Diff line change @@ -119,7 +119,9 @@ newtype TNode =
119
119
/** A synthetic node representing a captured variable. */
120
120
TCaptureNode ( VariableCapture:: Flow:: SynthesizedCaptureNode cn ) or
121
121
/** TODO: extende to also cover lambdas */
122
- TLambdaSelfReferenceNode ( Function f )
122
+ TLambdaSelfReferenceNode ( Function f ) {
123
+ f = any ( VariableCapture:: CapturedVariable v ) .getACapturingScope ( )
124
+ }
123
125
124
126
private import semmle.python.internal.CachedStages
125
127
You can’t perform that action at this time.
0 commit comments