ruby: test for DeadStore and captured variables

This commit is contained in:
yoff
2025-05-13 15:08:01 +02:00
parent 20a012d5f1
commit 73bae1627b
2 changed files with 31 additions and 0 deletions

View File

@@ -1 +1,2 @@
| 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 |
| 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 |

View File

@@ -33,4 +33,34 @@ class Sub < Sup
y = 3 # OK - the call to `super` sees the value of `y``
super
end
end
def do_twice
yield
yield
end
def get_done_twice x
do_twice do
print x
x += 1 # OK - the block is executed twice
end
end
def retry_once
yield
rescue
yield
end
def get_retried x
retry_once do
print x
if x < 1
begin
x += 1 #$ SPURIOUS: Alert
raise StandardError
end
end
end
end