Skip to content

fix(ruby): scope block-parameter args fallback to define_method's own body - #2260

Merged
squid-protocol merged 3 commits into
mainfrom
fix/ruby-2241-args-scope
Aug 26, 2026
Merged

squid-protocol merged 3 commits into
mainfrom
fix/ruby-2241-args-scope

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

Fixes #2241. The ruby args rule's do |...|/{ |...| } fallback (intended for define_method(:x) do |a,b| ... end, which has no def(...) at all) was found via a whole-method-body search, not scoped to be the method's own body-opening construct. It matched the first unrelated iterator block found anywhere inside a normal, paren-less def, misattributing that block's own parameter as the method's own argument count.

Fix

Anchored the fallback alternative to \A(?!\s*\bdef\b) so it's only reachable when the searched text does not begin with a real def -- unreachable for a def-declared method's body, while still matching bare define_method(:x) do |...|/{ |...| } shapes with no def wrapper.

Evidence

Real methods in language-crucible/data/ruby/rails/*.rb, before → after:

Method Before After
touch_attachments 1 0
add_digests 1 0
mail 1 0
generate_guides 1 0
guides_to_generate 1 0
copy_assets 1 0

All six now match tree-sitter/ctags ground truth (0 args). The original define_method(:x) do |a,b| ... end case this fallback was built for is unchanged (still correctly reports the block params).

Verification

  • pytest tests/extraction/languages/test_ruby.py -q -- 4 passed (func_start, class_start, args, dependency_capture; args gauntlet includes 4 new regression cases)
  • audit_check.py --ci -- clean
  • crucible_check.py --mode both -- drift confined to ruby/rails (Function Analysis changes, attributable) plus expected global coordinate ripple, blessed
  • tree_sitter_accuracy_audit.py --all --ci -- clean
  • tri_comparison_chart.py --all --ci -- clean

🤖 Generated with Gemini (via agy), orchestrated and independently verified by Claude Code.

squid-protocol and others added 3 commits August 26, 2026 09:48
… body

The ruby args rule's do|...|/{ |...| } fallback (intended for
define_method(:x) do |a,b| ... end, which has no def(...) at all) was
found via a whole-body search, not scoped to be the method's own
body-opening construct. It matched the first unrelated iterator block
found anywhere inside a normal, paren-less def, misattributing that
block's own parameter as the method's own argument count.

Anchored the fallback to \A(?!\s*\bdef\b) so it's only reachable when
the searched text does not begin with a real def -- unreachable for a
def-declared method's body, still matching bare
define_method(:x) do |...|/{ |...| } shapes with no def wrapper.

Confirmed on language-crucible's rails corpus: touch_attachments,
add_digests, mail, generate_guides, guides_to_generate, copy_assets
all went from a misattributed args=1 to the correct args=0, matching
tree-sitter/ctags ground truth.

Closes #2241

Co-Authored-By: Claude Sonnet 5 <[email protected]>
# Conflicts:
#	tests/golden_master_audit.json
#	tests/golden_master_zero_dep_audit.json
Reflects main's already-landed #2238/#2240 baselines together with
this branch's own ruby args-scoping fix.
@squid-protocol
squid-protocol merged commit d914281 into main Aug 26, 2026
28 checks passed
@squid-protocol
squid-protocol deleted the fix/ruby-2241-args-scope branch August 26, 2026 13:59
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant