From: "ufuk (Ufuk Kayserilioglu) via ruby-core" Date: 2025-04-29T11:15:10+00:00 Subject: [ruby-core:121768] [Ruby Bug#21292] wrong number of arguments (given 2, expected 0) (ArgumentError) since 8ac8225c504dee57454131e7cde2c47126596fdc Issue #21292 has been updated by ufuk (Ufuk Kayserilioglu). Assignee set to tenderlovemaking (Aaron Patterson) This seems to be related to the `Class#new` optimization. Assigning to @tenderlovemaking ---------------------------------------- Bug #21292: wrong number of arguments (given 2, expected 0) (ArgumentError) since 8ac8225c504dee57454131e7cde2c47126596fdc https://bugs.ruby-lang.org/issues/21292#change-112825 * Author: yahonda (Yasuo Honda) * Status: Open * Assignee: tenderlovemaking (Aaron Patterson) * ruby -v: ruby 3.5.0dev (2025-04-25T20:46:05Z master 8ac8225c50) +PRISM [x86_64-linux] * Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN ---------------------------------------- Rails CI against Ruby master branch has been failing https://buildkite.com/rails/rails-nightly/builds/2129#019673e6-eed1-4ce3-947b-be63f9b54f1a/1241-1249 According to git bisect, this behavior change has been introduced via 8ac8225c504dee57454131e7cde2c47126596fdc and I think I have managed to reproduce it. ### Steps to reproduce 1. Create foo.rb ```ruby class Foo def initialize @foo = nil end class << self private def method_missing(method_name, ...) Bar.new(self, method_name, ...) end # Workaround for Ruby 3.5.0 # def method_missing(method_name, *args, &block) # Bar.new(self, method_name, *args, &block) # end end end class Bar def initialize(class_name, action, *args) @class_name = class_name @action = action @args = args end end p RUBY_VERSION foo = Foo.hello p foo ``` 2. Run this foo.rb ``` $ ruby foo.rb ``` ### Expected behavior It should show the Ruby version and local variable foo as Ruby 3.4.3 does ```ruby $ ruby -v ruby 3.4.3 (2025-04-14 revision d0b7e5b6a0) +PRISM [x86_64-linux] $ ruby foo.rb "3.4.3" # $ ``` ### Actual behavior It raises the wrong number of arguments (given 2, expected 0) (ArgumentError) ```ruby $ ruby -v ruby 3.5.0dev (2025-04-25T20:46:05Z master 8ac8225c50) +PRISM [x86_64-linux] $ ruby foo.rb "3.5.0" foo.rb:2:in 'initialize': wrong number of arguments (given 2, expected 0) (ArgumentError) from foo.rb:10:in 'Foo.method_missing' from foo.rb:29:in '
' $ ``` ### Additional information 1. To workaround this error, update the method_missing signature as follows. ``` def method_missing(method_name, *args, &block) Bar.new(self, method_name, *args, &block) end ```` 2. This does not reproduce against e0545a0250 that is the parent commit of 8ac8225 ```ruby $ ruby -v ruby 3.5.0dev (2025-04-25T18:04:45Z master e0545a0250) +PRISM [x86_64-linux] $ ruby foo.rb "3.5.0" # $ ``` -- 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/