Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Ruby: More captured exit read nodes #19483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* Captured variables are currently considered live when the capturing function exits normally. Now they are also considered live when the capturing function exits via an exception.
1 change: 0 additions & 1 deletion 1 ruby/ql/lib/codeql/ruby/dataflow/internal/SsaImpl.qll
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ private predicate writesCapturedVariable(Cfg::BasicBlock bb, LocalVariable v) {
* at index `i` in exit block `bb`.
*/
private predicate capturedExitRead(Cfg::AnnotatedExitBasicBlock bb, int i, LocalVariable v) {
bb.isNormal() and
writesCapturedVariable(bb.getAPredecessor*(), v) and
i = bb.length()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,34 @@ def m(y)
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 # OK - the block may be executed again
raise StandardError
end
end
end
end
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.