Skip to content

Ruby: add qltest documenting implicit return dataflow gaps - #22272

Draft
aschackmull with Copilot wants to merge 1 commit into
mainfrom
copilot/add-qltest-documenting-existing-behavior
Draft

Ruby: add qltest documenting implicit return dataflow gaps#22272
aschackmull with Copilot wants to merge 1 commit into
mainfrom
copilot/add-qltest-documenting-existing-behavior

Conversation

Copilot AI commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Ruby's dataflow ExprReturnNode only recognises implicit returns that are direct statements of the method body (c.getBody().getAStmt()), missing cases where the returned value is in a rescue, else, or a body with ensure present.

New test: implicit-return

Six cases, all using implicit returns (no return keyword):

# Works: simple body return
def m_body
  source(1)
end
sink(m_body) # $ hasValueFlow=1

# Missing: body return when ensure is present
def m_body_ensure
  source(2)
ensure
  nil
end
sink(m_body_ensure) # $ MISSING: hasValueFlow=2

# Missing: rescue clause
def m_rescue
  raise "error"
rescue
  source(3)
end
sink(m_rescue) # $ MISSING: hasValueFlow=3

# Also MISSING: rescue+ensure, else, else+ensure

MISSING: annotations document known gaps without causing test failures; the framework will emit "Fixed missing result" when the bug is eventually addressed.

Documents existing behavior for implicit returns (no return keyword)
from:
- method body with ensure present
- rescue clause (with and without ensure)
- else clause (with and without ensure)

The test shows that only simple body returns currently work; all other
cases are marked MISSING to document the known gaps.
Copilot AI changed the title Ruby: add qltest for implicit return steps Ruby: add qltest documenting implicit return dataflow gaps Aug 3, 2026
Copilot AI requested a review from aschackmull August 3, 2026 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants