Issue #21807 has been reported by taichi730 (Taichi Ishitani). ---------------------------------------- Bug #21807: ArgumentError is reported when forwarding arguments to method with intermediate optional arguments https://bugs.ruby-lang.org/issues/21807 * Author: taichi730 (Taichi Ishitani) * Status: Open * ruby -v: 3.4.8 * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- In Ruby 3.4.x, @ArgumentError@ is reported when forwarding arguments to a method with intermediate optional arguments. How to reproduce: Execute sample below. ``` ruby class Foo def foo(a = nil, b) p a, b end end class Bar def initialize @foo = Foo.new end def bar(...) @foo.foo(...) @foo.foo(...) end end class Baz def initialize @bar = Bar.new end def baz(_a, ...) @bar.bar(...) end end puts RUBY_VERSION baz = Baz.new baz.baz(0, 1) ``` output: <pre> $ RBENV_VERSION=3.4.8 ruby test.rb 3.4.8 nil 1 test.rb:2:in 'foo': wrong number of arguments (given 0, expected 1..2) (ArgumentError) from test.rb:14:in 'Bar#bar' from test.rb:24:in 'Baz#baz' </pre> <pre> $ RBENV_VERSION=3.4.1 ruby test.rb 3.4.1 nil 1 test.rb:2:in 'foo': wrong number of arguments (given 0, expected 1..2) (ArgumentError) from test.rb:14:in 'Bar#bar' from test.rb:24:in 'Baz#baz' </pre> For other Ruby verions (e.g. 4.0.0, 3.3.0), no error is reported. <pre> $ RBENV_VERSION=4.0.0 ruby test.rb 4.0.0 nil 1 nil 1 </pre> <pre> $ RBENV_VERSION=3.3.0 ruby test.rb 3.3.0 nil 1 nil 1 </pre> -- https://bugs.ruby-lang.org/