Issue #15138 has been updated by jeremyevans0 (Jeremy Evans).
Status changed from Open to Closed
With the acceptance of #14183, non-symbols are allowed in keyword hash splats:
```ruby
m(k: 1, **{2 => 3})
# [{:k=>1, 2=>3}]
m(**{4 => 5})
# [{4=>5}]
```
----------------------------------------
Bug #15138: non-symbol keyword in double splat, such as **{2 => 3}, raises TypeError or not
https://bugs.ruby-lang.org/issues/15138#change-81331
* Author: akr (Akira Tanaka)
* Status: Closed
* Priority: Normal
* Assignee:
* Target version:
* ruby -v:
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
I found that non-symbol keyword in double splat, such as `**{2 => 3}`,
raises TypeError in a situation and doesn't raise in another situation:
```
% ./ruby -ve '
def m(*a) p a end
m(k: 1, **{2 => 3}) # [{:k=>1, 2=>3}]
m(**{4 => 5}) # hash key 4 is not a Symbol (TypeError)
'
ruby 2.6.0dev (2018-09-18 trunk 64776) [x86_64-linux]
[{:k=>1, 2=>3}]
Traceback (most recent call last):
-e:4:in `<main>': hash key 4 is not a Symbol (TypeError)
```
It seems another keyword argument, `k: 0` here, prevent TypeError.
I think this behavior is not intentional.
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>