oracle / truffleruby

A high performance implementation of the Ruby programming language, built on GraalVM.
https://www.graalvm.org/ruby/
Other
2.98k stars 179 forks source link

Hash.to_h with block not yielding splat args well #3607

Closed HoneyryderChuck closed 3 days ago

HoneyryderChuck commented 1 week ago

Tested with latest (24.0.1):

value = {"a"=>1, "b"=>2}
value.to_h { |*args| puts args.inspect; args }

#=> ruby 3.3
# ["a", 1]
# ["b", 2]
# {"a"=>1, "b"=>2}

#=> truffleruby 24.0.1
[["a", 1]]
<internal:core> core/enumerable.rb:327:in `block in to_h': element has wrong array length (expected 2, was 1) (ArgumentError)
        from <internal:core> core/enumerable.rb:389:in `block in each_with_index'
        from <internal:core> core/enumerable.rb:387:in `each'
        from <internal:core> core/enumerable.rb:387:in `each_with_index'
andrykonchin commented 1 week ago

Thank you for the report, we'll look into it.

andrykonchin commented 3 days ago

Fixed in b0b947eb2a14480c91ce8cbd5e6d6e28e0a14a1b.