Actions
Bug #18185
closedBasicObject is inserted in the middle of the inheritance tree.
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.1.0dev (2021-09-22T10:04:55Z master 7c0230b05d) [arm64-darwin20]
Description
t.rb
#! /usr/bin/env ruby
class Mod < Module
module InstanceMethods
end
def initialize(aaa:)
include InstanceMethods
end
end
class Foo
def initialize(key:)
end
end
class Bar < Foo
include Mod.new(aaa: 1)
end
p Bar.ancestors
p Bar.new(key: 1)
3.0.2
$ ruby -v t.rb
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [arm64-darwin20]
[Bar, #<Mod:0x000000011e82ef50>, Mod::InstanceMethods, Foo, Object, Kernel, BasicObject]
#<Bar:0x000000011e82e640>
3.1.0-dev
$ ruby -v t.rb
ruby 3.1.0dev (2021-09-22T10:04:55Z master 7c0230b05d) [arm64-darwin20]
[Bar, #<Mod:0x000000010321f558>, Mod::InstanceMethods, BasicObject, Foo, Object, Kernel, BasicObject]
t.rb:20:in `initialize': wrong number of arguments (given 1, expected 0) (ArgumentError)
from t.rb:20:in `new'
from t.rb:20:in `<main>'
I found this problem when running the Rails db:schema:load
task.
Upon closer inspection, the following code seemed to be causing the problem.
https://github.com/rails/rails/blob/e44ce53f78fb376d8d48145e2319204a1a2ebfc9/activemodel/lib/active_model/type/date_time.rb#L8-L10
https://github.com/rails/rails/blob/e44ce53f78fb376d8d48145e2319204a1a2ebfc9/activemodel/lib/active_model/type/helpers/accepts_multiparameter_time.rb
t.rb is a small reproduction of this problem.
This problem does not seem to occur in v3.0.2 of ruby.
Actions
Like0
Like0Like0Like0Like0