Skip to content

Commit f19232f

Browse files
committed
Ruby: Fix another bug in isCapturedAccess
1 parent f377d25 commit f19232f

File tree

3 files changed

+2
-36
lines changed

3 files changed

+2
-36
lines changed

ruby/ql/lib/codeql/ruby/ast/internal/Variable.qll

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -368,20 +368,8 @@ private module Cached {
368368
exists(Scope scope1, CfgScope scope2 |
369369
scope1 = access.getVariable().getDeclaringScope() and
370370
scope2 = access.getCfgScope() and
371-
scope1 != scope2
372-
|
373-
if access instanceof SelfVariableAccess
374-
then
375-
// ```
376-
// class C
377-
// def self.m // not a captured access
378-
// end
379-
//
380-
// self.foo // not a captured access
381-
// end
382-
// ```
383-
not scope2 instanceof Toplevel
384-
else any()
371+
scope1 != scope2 and
372+
not scope2 instanceof Toplevel
385373
)
386374
}
387375

ruby/ql/test/library-tests/variables/ssa.expected

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,9 @@ definition
103103
| scopes.rb:26:1:26:12 | self (A) | scopes.rb:26:1:26:12 | self |
104104
| scopes.rb:27:1:27:1 | x | scopes.rb:27:1:27:1 | x |
105105
| scopes.rb:28:1:30:3 | self (B) | scopes.rb:28:1:30:3 | self |
106-
| scopes.rb:29:3:29:3 | x | scopes.rb:29:3:29:3 | x |
107-
| scopes.rb:32:3:32:3 | x | scopes.rb:32:3:32:3 | x |
108106
| scopes.rb:34:1:36:3 | self (C) | scopes.rb:34:1:36:3 | self |
109-
| scopes.rb:35:3:35:3 | x | scopes.rb:35:3:35:3 | x |
110107
| scopes.rb:41:1:49:3 | self (M) | scopes.rb:41:1:49:3 | self |
111108
| scopes.rb:42:2:42:4 | var | scopes.rb:42:2:42:4 | var |
112-
| scopes.rb:43:2:43:4 | foo | scopes.rb:43:2:43:4 | foo |
113109
| scopes.rb:46:5:46:8 | var2 | scopes.rb:46:5:46:8 | var2 |
114110
| ssa.rb:1:1:16:3 | self (m) | ssa.rb:1:1:16:3 | self |
115111
| ssa.rb:1:7:1:7 | b | ssa.rb:1:7:1:7 | b |

ruby/ql/test/library-tests/variables/varaccess.expected

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -619,18 +619,8 @@ readAccess
619619
captureAccess
620620
| instance_variables.rb:28:3:28:4 | self |
621621
| instance_variables.rb:32:12:32:13 | self |
622-
| nested_scopes.rb:5:3:5:3 | a |
623-
| nested_scopes.rb:7:5:7:5 | a |
624-
| nested_scopes.rb:9:7:9:7 | a |
625-
| nested_scopes.rb:11:9:11:9 | a |
626622
| nested_scopes.rb:18:29:18:34 | self |
627623
| nested_scopes.rb:18:34:18:34 | a |
628-
| nested_scopes.rb:25:14:25:14 | a |
629-
| nested_scopes.rb:31:11:31:11 | a |
630-
| nested_scopes.rb:32:16:32:16 | a |
631-
| nested_scopes.rb:34:12:34:12 | a |
632-
| nested_scopes.rb:36:10:36:10 | a |
633-
| nested_scopes.rb:38:8:38:8 | a |
634624
| parameters.rb:3:4:3:9 | self |
635625
| parameters.rb:4:4:4:9 | self |
636626
| parameters.rb:17:5:17:28 | self |
@@ -653,14 +643,6 @@ captureAccess
653643
| scopes.rb:15:4:15:9 | self |
654644
| scopes.rb:16:4:16:9 | self |
655645
| scopes.rb:17:4:17:9 | self |
656-
| scopes.rb:29:3:29:3 | x |
657-
| scopes.rb:32:3:32:3 | x |
658-
| scopes.rb:35:3:35:3 | x |
659-
| scopes.rb:42:2:42:4 | var |
660-
| scopes.rb:43:2:43:4 | foo |
661-
| scopes.rb:44:5:44:7 | var |
662-
| scopes.rb:46:5:46:8 | var2 |
663-
| scopes.rb:47:5:47:8 | var2 |
664646
| ssa.rb:26:7:26:10 | elem |
665647
| ssa.rb:27:5:27:13 | self |
666648
| ssa.rb:27:10:27:13 | elem |

0 commit comments

Comments
 (0)