* [ruby-core:122935] [Ruby Bug#21535] `NoMethodError` becomes `NameError`when using `...` delegation and method call indirection
@ 2025-08-08 7:42 Earlopain (Earlopain _) via ruby-core
2025-08-08 7:55 ` [ruby-core:122936] " Earlopain (Earlopain _) via ruby-core
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Earlopain (Earlopain _) via ruby-core @ 2025-08-08 7:42 UTC (permalink / raw)
To: ruby-core; +Cc: Earlopain (Earlopain _)
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/
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ruby-core:122936] [Ruby Bug#21535] `NoMethodError` becomes `NameError`when using `...` delegation and method call indirection
2025-08-08 7:42 [ruby-core:122935] [Ruby Bug#21535] `NoMethodError` becomes `NameError`when using `...` delegation and method call indirection Earlopain (Earlopain _) via ruby-core
@ 2025-08-08 7:55 ` Earlopain (Earlopain _) via ruby-core
2025-08-10 7:46 ` [ruby-core:122942] " byroot (Jean Boussier) via ruby-core
2025-08-27 22:26 ` [ruby-core:123095] " alanwu (Alan Wu) via ruby-core
2 siblings, 0 replies; 4+ messages in thread
From: Earlopain (Earlopain _) via ruby-core @ 2025-08-08 7:55 UTC (permalink / raw)
To: ruby-core; +Cc: Earlopain (Earlopain _)
Issue #21535 has been updated by Earlopain (Earlopain _).
Maybe https://bugs.ruby-lang.org/issues/21196 is of relevance
----------------------------------------
Bug #21535: `NoMethodError` becomes `NameError`when using `...` delegation and method call indirection
https://bugs.ruby-lang.org/issues/21535#change-114242
* 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/
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ruby-core:122942] [Ruby Bug#21535] `NoMethodError` becomes `NameError`when using `...` delegation and method call indirection
2025-08-08 7:42 [ruby-core:122935] [Ruby Bug#21535] `NoMethodError` becomes `NameError`when using `...` delegation and method call indirection Earlopain (Earlopain _) via ruby-core
2025-08-08 7:55 ` [ruby-core:122936] " Earlopain (Earlopain _) via ruby-core
@ 2025-08-10 7:46 ` byroot (Jean Boussier) via ruby-core
2025-08-27 22:26 ` [ruby-core:123095] " alanwu (Alan Wu) via ruby-core
2 siblings, 0 replies; 4+ messages in thread
From: byroot (Jean Boussier) via ruby-core @ 2025-08-10 7:46 UTC (permalink / raw)
To: ruby-core; +Cc: byroot (Jean Boussier)
Issue #21535 has been updated by byroot (Jean Boussier).
Backport changed from 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN to 3.2: DONTNEED, 3.3: DONTNEED, 3.4: REQUIRED
I ran a bisect and as suspected this regression was caused by the forward call optimization in https://github.com/ruby/ruby/commit/cdf33ed5f37f9649c482c3ba1d245f0d80ac01ce
FYI: @tenderlovemaking
----------------------------------------
Bug #21535: `NoMethodError` becomes `NameError`when using `...` delegation and method call indirection
https://bugs.ruby-lang.org/issues/21535#change-114248
* 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: DONTNEED, 3.3: DONTNEED, 3.4: REQUIRED
----------------------------------------
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/
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ruby-core:123095] [Ruby Bug#21535] `NoMethodError` becomes `NameError`when using `...` delegation and method call indirection
2025-08-08 7:42 [ruby-core:122935] [Ruby Bug#21535] `NoMethodError` becomes `NameError`when using `...` delegation and method call indirection Earlopain (Earlopain _) via ruby-core
2025-08-08 7:55 ` [ruby-core:122936] " Earlopain (Earlopain _) via ruby-core
2025-08-10 7:46 ` [ruby-core:122942] " byroot (Jean Boussier) via ruby-core
@ 2025-08-27 22:26 ` alanwu (Alan Wu) via ruby-core
2 siblings, 0 replies; 4+ messages in thread
From: alanwu (Alan Wu) via ruby-core @ 2025-08-27 22:26 UTC (permalink / raw)
To: ruby-core; +Cc: alanwu (Alan Wu)
Issue #21535 has been updated by alanwu (Alan Wu).
Backport changed from 3.2: DONTNEED, 3.3: DONTNEED, 3.4: REQUIRED to 3.2: DONTNEED, 3.3: DONTNEED, 3.4: DONE
Backport for 3.4 done in commit:0d367ce65fe4e85f207a8ca5f1f331dd90c6992e
----------------------------------------
Bug #21535: `NoMethodError` becomes `NameError`when using `...` delegation and method call indirection
https://bugs.ruby-lang.org/issues/21535#change-114409
* Author: Earlopain (Earlopain _)
* Status: Closed
* ruby -v: ruby 3.5.0dev (2025-08-08T02:57:23Z master 3ad26d0501) +PRISM [x86_64-linux]
* Backport: 3.2: DONTNEED, 3.3: DONTNEED, 3.4: DONE
----------------------------------------
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/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-08-27 22:27 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-08 7:42 [ruby-core:122935] [Ruby Bug#21535] `NoMethodError` becomes `NameError`when using `...` delegation and method call indirection Earlopain (Earlopain _) via ruby-core
2025-08-08 7:55 ` [ruby-core:122936] " Earlopain (Earlopain _) via ruby-core
2025-08-10 7:46 ` [ruby-core:122942] " byroot (Jean Boussier) via ruby-core
2025-08-27 22:26 ` [ruby-core:123095] " alanwu (Alan Wu) via ruby-core
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).