Skip to content

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

Merged
aschackmull merged 2 commits into
mainfrom
copilot/add-qltest-documenting-existing-behavior
Aug 4, 2026
Merged

Ruby: add qltest documenting implicit return dataflow gaps#22272
aschackmull merged 2 commits into
mainfrom
copilot/add-qltest-documenting-existing-behavior

Conversation

CopilotAI 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 returndefm_bodysource(1)endsink(m_body)# $ hasValueFlow=1# Missing: body return when ensure is presentdefm_body_ensuresource(2)ensurenilendsink(m_body_ensure)# $ MISSING: hasValueFlow=2# Missing: rescue clausedefm_rescueraise"error"rescuesource(3)endsink(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.
CopilotAI changed the title Ruby: add qltest for implicit return stepsRuby: add qltest documenting implicit return dataflow gapsAug 3, 2026
CopilotAI requested a review from aschackmullAugust 3, 2026 12:59

@aschackmullaschackmull left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tweaks

Comment threadruby/ql/test/library-tests/dataflow/implicit-return/implicit_return.rb Outdated
Comment threadruby/ql/test/library-tests/dataflow/implicit-return/implicit_return.rb Outdated
Comment threadruby/ql/test/library-tests/dataflow/implicit-return/implicit_return.rb Outdated
Comment threadruby/ql/test/library-tests/dataflow/implicit-return/implicit_return.rb Outdated
Co-authored-by: Anders Schack-Mulligen <aschackmull@users.noreply.github.com>
@aschackmullaschackmull added the no-change-note-required This PR does not need a change note label Aug 4, 2026
@aschackmull
aschackmull marked this pull request as ready for review August 4, 2026 06:58
@aschackmull
aschackmull requested a review from a team as a code ownerAugust 4, 2026 06:58
CopilotAI balanced review requested due to automatic review settings August 4, 2026 06:58

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a focused Ruby data-flow regression test documenting known implicit-return gaps.

Changes:

  • Covers method body, rescue, and else implicit returns with optional ensure.
  • Marks known missing flows without failing the test.
Show a summary per file
FileDescription
implicit-return.qlDefines the path query.
implicit-return.expectedRecords current results.
implicit_return.rbProvides inline flow cases and expectations.

Review details

  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment on lines +3 to +4
# An implicit return is when no `return` statement is used; instead the
# last evaluated expression is returned.
@aschackmull
aschackmull merged commit 70bfecc into mainAug 4, 2026
12 checks passed
@aschackmull
aschackmull deleted the copilot/add-qltest-documenting-existing-behavior branch August 4, 2026 07:51
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-change-note-requiredThis PR does not need a change noteRuby

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@hvitved@aschackmull