Skip to content

Fix parser method redefinition warnings - #1694

Merged
lsegal merged 2 commits into
mainfrom
fix/issue-1687-method-redefined-warnings
Jul 14, 2026
Merged

Fix parser method redefinition warnings#1694
lsegal merged 2 commits into
mainfrom
fix/issue-1687-method-redefined-warnings

Conversation

@lsegal

@lsegal lsegal commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Summary

Ruby 4.0 warns when YARD loads because Ripper's parser event table generates default handlers for on_hshptn, on_aryptn, and on_fndptn before 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 -w and 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

@lsegal
lsegal merged commit 674d0cf into main Jul 14, 2026
50 checks passed
@lsegal
lsegal deleted the fix/issue-1687-method-redefined-warnings branch July 14, 2026 20:03
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.

method redefined warnings with yard 0.9.44

1 participant