Project

General

Profile

Actions

Bug #16642

closed

Splatted empty hash literal produces frozen hash object

Added by Dan0042 (Daniel DeLorme) about 4 years ago. Updated about 4 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.7.1p37 (2020-02-20) [x86_64-openbsd6.6]
[ruby-core:97203]

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

ruby2_keywords-empty-kw-splat-16642.patch (2.49 KB) ruby2_keywords-empty-kw-splat-16642.patch jeremyevans0 (Jeremy Evans), 02/24/2020 09:22 PM
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0