Actions
Bug #16642
closedSplatted empty hash literal produces frozen hash object
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.7.1p37 (2020-02-20) [x86_64-openbsd6.6]
Description
When splatting an empty hash literal, internally it's optimized using a global frozen hash object, but this implementation detail can leak into the ruby code outside:
ruby2_keywords def foo(*a) a.last end
h = foo(**{})
h[1] = 2
# can't modify frozen Hash: {} (FrozenError)
I think this can be considered a bug?
Files
Actions
Like0
Like0Like0Like0Like0