Actions
Bug #15138
closednon-symbol keyword in double splat, such as **{2 => 3}, raises TypeError or not
Description
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.
Updated by jeremyevans0 (Jeremy Evans) over 5 years ago
- Status changed from Open to Closed
With the acceptance of #14183, non-symbols are allowed in keyword hash splats:
m(k: 1, **{2 => 3})
# [{:k=>1, 2=>3}]
m(**{4 => 5})
# [{4=>5}]
Actions
Like0
Like0