Project

General

Profile

Actions

Bug #20229

closed

Empty keyword splat in array not removed in ARGSPUSH case

Added by jeremyevans0 (Jeremy Evans) 3 months ago. Updated 3 months ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:116516]

Description

For the following code:

a = []
kw = {}
[*a, **kw]

Ruby 2.0-3.3 return [{}], when the desired result (since 2.7) is [].

I discovered this while working on an optimization for the ARGSCAT case, where [*a, 1, **kw] allocates two arrays instead of a single array. My optimization fixes that by adding a pushtoarraykwsplat instruction as a replacement for newarraykwsplat. I've used pushtoarraykwsplat in the ARGSPUSH case to fix this bug.

My pull request for the bug fix and optimization: https://github.com/ruby/ruby/pull/9766


Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #20180: Inconsistent evaluation of `**{}` depending on position in arrayClosedActions
Actions #1

Updated by jeremyevans0 (Jeremy Evans) 3 months ago

  • Related to Bug #20180: Inconsistent evaluation of `**{}` depending on position in array added

Updated by jeremyevans0 (Jeremy Evans) 3 months ago

I found that this bug was actually reported earlier in #20180, which I already have submitted a pull request to fix. I think we should use the approach in this pull request to fix this issue in master, as it is more efficient. We could backport the fix in #20180 to Ruby 3.1-3.3.

Updated by jeremyevans0 (Jeremy Evans) 3 months ago

  • Status changed from Open to Closed
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0