Repository navigation
fix(ruby): scope block-parameter args fallback to define_method's own body - #2260
Merged
Merged
Conversation
… 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
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2241. The ruby
argsrule'sdo |...|/{ |...| }fallback (intended fordefine_method(:x) do |a,b| ... end, which has nodef(...)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-lessdef, 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 realdef-- unreachable for adef-declared method's body, while still matching baredefine_method(:x) do |...|/{ |...| }shapes with nodefwrapper.Evidence
Real methods in
language-crucible/data/ruby/rails/*.rb, before → after:touch_attachmentsadd_digestsmailgenerate_guidesguides_to_generatecopy_assetsAll six now match tree-sitter/ctags ground truth (0 args). The original
define_method(:x) do |a,b| ... endcase 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-- cleancrucible_check.py --mode both-- drift confined to ruby/rails (Function Analysis changes, attributable) plus expected global coordinate ripple, blessedtree_sitter_accuracy_audit.py --all --ci-- cleantri_comparison_chart.py --all --ci-- clean🤖 Generated with Gemini (via
agy), orchestrated and independently verified by Claude Code.