Skip to content

Commit

Permalink
Implement no args Struct.new constructor in Ruby 3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
simonlevasseur committed Mar 14, 2024
1 parent c062749 commit 76375a7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions spec/truffleruby.next-specs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# Use spec/ruby/core/nil/nil_spec.rb as a dummy file to avoid being empty (what causes mspec to error)
spec/ruby/core/nil/nil_spec.rb

spec/ruby/core/struct/new_spec.rb
spec/ruby/core/warning/element_reference_spec.rb
spec/ruby/core/warning/element_set_spec.rb

Expand Down
2 changes: 1 addition & 1 deletion src/main/ruby/truffleruby/core/struct.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class << self
alias_method :subclass_new, :new
end

def self.new(klass_name, *attrs, keyword_init: nil, &block)
def self.new(klass_name = nil, *attrs, keyword_init: nil, &block)
if klass_name
if Primitive.is_a?(klass_name, Symbol) # Truffle: added to avoid exception and match MRI
attrs.unshift klass_name
Expand Down

0 comments on commit 76375a7

Please sign in to comment.