Closed
Description
It looks like TruffleRuby behaves differently when a Struct is initialized with both positional and keyword args.
Here's a test script to demonstrate:
#!/usr/bin/env ruby
puts ?=*72
puts "Ruby Engine: #{RUBY_ENGINE} #{RUBY_ENGINE_VERSION}"
Test = Struct.new(:foo, :attr)
puts " Keywords: %p" % [Test.new(foo: "foo", attr: {"bar" => "baz"})]
puts " Positional: %p" % [Test.new("foo", {"bar" => "baz"})]
puts " Mixed: %p" % [Test.new("foo", "bar" => "baz")]
puts " Mixed (2): %p" % [Test.new("foo", attr: {"bar" => "baz"})]
puts " Mixed (3): %p" % [Test.new("foo", attr: {weird: true}, "bar" => "baz")]
__END__
$ ruby test.rb && RBENV_VERSION=truffleruby-24.2.1 ruby test.rb
========================================================================
Ruby Engine: ruby 3.4.2
Keywords: #<struct Test foo="foo", attr={"bar" => "baz"}>
Positional: #<struct Test foo="foo", attr={"bar" => "baz"}>
Mixed: #<struct Test foo="foo", attr={"bar" => "baz"}>
Mixed (2): #<struct Test foo="foo", attr={attr: {"bar" => "baz"}}>
Mixed (3): #<struct Test foo="foo", attr={attr: {weird: true}, "bar" => "baz"}>
========================================================================
Ruby Engine: truffleruby 24.2.1
Keywords: #<struct Test foo="foo", attr={"bar"=>"baz"}>
Positional: #<struct Test foo="foo", attr={"bar"=>"baz"}>
Mixed: #<struct Test foo="foo", attr=nil>
Mixed (2): #<struct Test foo="foo", attr=nil>
Mixed (3): #<struct Test foo="foo", attr=nil>