From: "Earlopain (Earlopain _) via ruby-core" Date: 2025-08-08T07:42:49+00:00 Subject: [ruby-core:122935] [Ruby Bug#21535] `NoMethodError` becomes `NameError`when using `...` delegation and method call indirection Issue #21535 has been reported by Earlopain (Earlopain _). ---------------------------------------- Bug #21535: `NoMethodError` becomes `NameError`when using `...` delegation and method call indirection https://bugs.ruby-lang.org/issues/21535 * Author: Earlopain (Earlopain _) * Status: Open * ruby -v: ruby 3.5.0dev (2025-08-08T02:57:23Z master 3ad26d0501) +PRISM [x86_64-linux] * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- Consider this code: ```rb 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 ``` ```sh $ 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. -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/