Skip to content

Commit 647485a

Browse files
committed
Don't omit self from uninitialized writes
We can safely create uninitialized writes for `self` variables, because they appear at index -1 in the entry block of a method, and are immediately overwritten by a write to `self` at index 0. As a result, they are not live and will be pruned from the CFG.
1 parent 446eb13 commit 647485a

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

ruby/ql/lib/codeql/ruby/dataflow/internal/SsaImpl.qll

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ private import CfgNodes::ExprNodes
77
/** Holds if `v` is uninitialized at index `i` in entry block `bb`. */
88
predicate uninitializedWrite(EntryBasicBlock bb, int i, LocalVariable v) {
99
v.getDeclaringScope() = bb.getScope() and
10-
i = -1 and
11-
not v instanceof SelfVariable
10+
i = -1
1211
}
1312

1413
/** Holds if `bb` contains a caputured read of variable `v`. */

0 commit comments

Comments
 (0)