Actions
Bug #21535
closed`NoMethodError` becomes `NameError`when using `...` delegation and method call indirection
Bug #21535:
`NoMethodError` becomes `NameError`when using `...` delegation and method call indirection
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.5.0dev (2025-08-08T02:57:23Z master 3ad26d0501) +PRISM [x86_64-linux]
Description
Consider this code:
class Test
def foo(...)
nil.foo(...)
end
def foo_indirect
foo
end
end
begin
Test.new.foo
rescue => e
puts e.class
end
begin
Test.new.foo_indirect
rescue => e
puts e.class
end
$ ruby -v foo.rb
ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [x86_64-linux]
NoMethodError
NoMethodError
$ ruby -v foo.rb
ruby 3.5.0dev (2025-08-08T02:57:23Z master 3ad26d0501) +PRISM [x86_64-linux]
NoMethodError
NameError
On ruby 3.3 it used to always raise a NoMethodError. Starting with Ruby 3.4, it raises a NoMethodError when calling the method directly, and a NameError when the method is called indirectly via a different method.
The context is the delegate method from rails (original issue https://github.com/rails/rails/issues/55463), which rescues the NoMethodError to raise a more specific error class.
The problem is the ... delegation. If the method accepts no arguments, *, **, or something else, it behaves as expected.
Actions