Project

General

Profile

Bug #10016

Destructuring block arguments with a Hashable last element

Added by brixen (Brian Shirai) about 6 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
ruby -v:
ruby 2.2.0dev (2014-06-05 trunk 46353) [x86_64-darwin13]
[ruby-core:63593]

Description

The following code:

# destructure_bug.rb
def m
  x = Object.new
  def x.to_hash() {x: 9} end

  yield [1, 2, 3, x]
end

p m { |a, *b, c, **k| [a, b, c, k] }

gives:

$ ruby -v destructure_bug.rb
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
[#<Object:0x007fc5fb212870>, [nil], 1, {:x=>9}]

$ ruby -v destructure_bug.rb
ruby 2.2.0dev (2014-06-05 trunk 46353) [x86_64-darwin13]
[#<Object:0x007f88c206c2a8>, [nil], 1, {:x=>9}]

I would expect: [1, [2], 3, {:x=>9}]

Is this a bug?

Also available in: Atom PDF