Skip to content

Commit 77a3e4b

Browse files
committed
Ruby: CFG: fix completion of AsPattern variable
1 parent 9bd2ac9 commit 77a3e4b

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

ruby/ql/lib/codeql/ruby/controlflow/internal/ControlFlowGraphImpl.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,8 @@ module Trees {
711711
last(this.getPattern(), last, c) and
712712
c.(MatchingCompletion).getValue() = false
713713
or
714-
last(this.getVariableAccess(), last, c)
714+
last(this.getVariableAccess(), last, any(SimpleCompletion x)) and
715+
c.(MatchingCompletion).getValue() = true
715716
}
716717

717718
final override predicate succ(AstNode pred, AstNode succ, Completion c) {

ruby/ql/test/library-tests/controlflow/graph/Cfg.expected

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,8 +1190,14 @@ case.rb:
11901190
#-----| match -> x
11911191

11921192
# 82| x
1193+
#-----| match -> 1
1194+
1195+
# 82| then ...
11931196
#-----| -> case ...
11941197

1198+
# 82| 1
1199+
#-----| -> then ...
1200+
11951201
# 83| in ... then ...
11961202
#-----| -> ... | ...
11971203

ruby/ql/test/library-tests/controlflow/graph/case.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def case_match_various value
7979
in 5 .. 10
8080
in .. 10
8181
in 5 ..
82-
in 5 => x
82+
in 5 => x then 1
8383
in 5 | ^foo | "string"
8484
in ::Foo::Bar
8585
in -> x { x == 10 }

0 commit comments

Comments
 (0)