Issue #11129 has been updated by Sean Linsley.


I'd rename this bug to something like "block-level hash destructuring only works for the last argument" if Redmine let you rename bugs...

----------------------------------------
Bug #11129: each_with_index doesn't work with block-level hash destructuring
https://bugs.ruby-lang.org/issues/11129#change-52339

* Author: Sean Linsley
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: 2.2
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
```ruby
[{a: 2}].each_with_index{ |a:, index| }
SyntaxError: unexpected tIDENTIFIER

[{a: 2}].each_with_index{ |(a:), index| }
SyntaxError: unexpected tLABEL

[{a: 2}].each_with_index.map{ |hash, index| [index, hash] }.map{ |index, a:| p [index, a] }
== [0, 2]
```

It seems like the second example should work, in the same way that parentheses in `||` destructure arrays.



-- 
https://bugs.ruby-lang.org/