From: "taichi730 (Taichi Ishitani) via ruby-core" Date: 2025-12-26T03:40:06+00:00 Subject: [ruby-core:124366] [Ruby Bug#21807] ArgumentError is reported when forwarding arguments to method with intermediate optional arguments 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:
$ 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'
$ 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'
For other Ruby verions (e.g. 4.0.0, 3.3.0), no error is reported.
$ RBENV_VERSION=4.0.0 ruby test.rb
4.0.0
nil
1
nil
1
$ RBENV_VERSION=3.3.0 ruby test.rb
3.3.0
nil
1
nil
1
-- 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/