Fix parser method redefinition warnings - #1694
Merged
Merged
Conversation
lsegal
added a commit
that referenced
this pull request
Jul 14, 2026
References: #1695, #1684, #1694, #1687, #1684, #1686, #1687, #1686, #1685, #1688, #1688, #1627, #1680, #1583, #1660, #1639, #1636, #1528, #1, #1434, #1385, #1294, #1019, #1007, #955, #929, #623, #474, #467, #456, #467, #443, #467, #478, #479, #467, #477, #467, #458, #467, #397, #467, #461, #467, #458, #467, #457, #467, #465, #467, #464, #467, #466, #467, #446, #467, #445, #467, #432, #467
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
Ruby 4.0 warns when YARD loads because Ripper's parser event table generates default handlers for
on_hshptn,on_aryptn, andon_fndptnbefore YARD replaces them with specialized pattern-matching handlers.This change explicitly undefines each generated callback before defining its specialized implementation. Pattern-matching behavior remains unchanged, while loading YARD with Ruby warnings enabled no longer emits method-redefinition warnings.
The unreleased changelog now records the fix, and a subprocess regression spec loads YARD under
ruby -wand verifies both a successful load and the absence of method-redefinition warnings.Tests
bundle exec rspec spec/parser/ruby/ruby_parser_spec.rb(100 examples, 0 failures)bundle exec rake(2,785 examples, 0 failures; documentation generation passed)ruby -w -Ilib -e "require 'yard'; YARD.parse"(no parser method-redefinition warnings)Closes #1687