Repository navigation
Deprecate the fallback to Object for alias in a module - #18740
Merged
Merged
Conversation
shugo
marked this pull request as ready for review
September 10, 2026 11:01
shugo
force-pushed
the
fix/deprecate-alias-object-fallback
branch
from
September 11, 2026 00:29
9768d87 to
341585b
Compare
`alias` and `Module#alias_method` in a module fall back to searching the method from Object when the module and its ancestors do not have it. The fallback assumes Object is the root class, which is no longer true since BasicObject was introduced in 1.9, so Matz decided to remove it. As the first step, warn in verbose mode when the fallback is used; the plan is to warn unconditionally in 4.2 and to raise NameError in 4.3. https://bugs.ruby-lang.org/issues/22276 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
shugo
force-pushed
the
fix/deprecate-alias-object-fallback
branch
from
September 17, 2026 01:06
341585b to
5de05df
Compare
shugo
enabled auto-merge (rebase)
September 17, 2026 01:06
2 of 4 tasks
yahonda
added a commit
to rails/rails
that referenced
this pull request
Sep 20, 2026
Ruby master branch (ruby 4.1.0dev) now warns when `alias` in a module falls back to `Object`. The plan is to raise `NameError` in Ruby 4.3. https://bugs.ruby-lang.org/issues/22276 ruby/ruby#18740 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2 of 4 tasks
yahonda
added a commit
to yahonda/rails
that referenced
this pull request
Oct 12, 2026
Ruby master branch (ruby 4.1.0dev) now warns when `alias` in a module falls back to `Object`. The plan is to raise `NameError` in Ruby 4.3. https://bugs.ruby-lang.org/issues/22276 ruby/ruby#18740 This is the same approach as rails#56705 for `read_attribute_for_serialization`, extracted from rails#56130 without its behavior change. Co-authored-by: Lovro Bikic <lovro.bikic@infinum.hr> Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
aliasandModule#alias_methodin a module fall back to searching the method from Object when the module and its ancestors do not have it. The fallback assumes Object is the root class, which is no longer true since BasicObject was introduced in 1.9, so Matz decided to remove it. As the first step, warn in verbose mode when the fallback is used; the plan is to warn unconditionally in 4.2 and to raise NameError in 4.3.https://bugs.ruby-lang.org/issues/22276