Skip to content

Commit 73bae16

Browse files
committed
ruby: test for DeadStore and captured variables
1 parent 20a012d commit 73bae16

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
| DeadStoreOfLocal.rb:2:5:2:5 | y | This assignment to $@ is useless, since its value is never read. | DeadStoreOfLocal.rb:2:5:2:5 | y | y |
2+
| DeadStoreOfLocal.rb:61:17:61:17 | x | This assignment to $@ is useless, since its value is never read. | DeadStoreOfLocal.rb:56:17:56:17 | x | x |

ruby/ql/test/query-tests/variables/DeadStoreOfLocal/DeadStoreOfLocal.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,34 @@ def m(y)
3333
y = 3 # OK - the call to `super` sees the value of `y``
3434
super
3535
end
36+
end
37+
38+
def do_twice
39+
yield
40+
yield
41+
end
42+
43+
def get_done_twice x
44+
do_twice do
45+
print x
46+
x += 1 # OK - the block is executed twice
47+
end
48+
end
49+
50+
def retry_once
51+
yield
52+
rescue
53+
yield
54+
end
55+
56+
def get_retried x
57+
retry_once do
58+
print x
59+
if x < 1
60+
begin
61+
x += 1 #$ SPURIOUS: Alert
62+
raise StandardError
63+
end
64+
end
65+
end
3666
end

0 commit comments

Comments
 (0)