Project

General

Profile

Actions

Bug #15052

closed

must not optimize `foo(**{})` out

Added by mame (Yusuke Endoh) over 6 years ago. Updated about 5 years ago.

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

Description

A keyword rest argument with empty hash, **{}, is removed during parsing phase. However, under the current spec of keyword parameters, this leads to a problem:

def foo(opt = "opt", **hsh)
  p [opt, hsh]
end

foo({}, **{})  #=> expected: [{}, {}], actual: ["opt", {}]

foo({}, **{}) is obviously expected to pass the first {} to opt, and the second **{} to **hsh. However, **{} is removed at parsing phase, sp the first {} is considered as a keyword rest argument, which causes the above strange result.

So, we cannot optimize **{} out, unless keyword argument is separated from normal arguments #14183. (The current spec is really intractable not only for Ruby users but also for Ruby developers!)


Files


Related issues 2 (0 open2 closed)

Related to Ruby master - Bug #15078: Hash splat of empty hash should not create a positional argument.Closedmatz (Yukihiro Matsumoto)Actions
Related to Ruby master - Bug #15087: Segmentation fault with splat and blockClosedActions
Actions #1

Updated by mame (Yusuke Endoh) over 6 years ago

  • Related to Bug #15078: Hash splat of empty hash should not create a positional argument. added
Actions #2

Updated by mame (Yusuke Endoh) over 6 years ago

  • Related to Bug #15087: Segmentation fault with splat and block added

Updated by jeremyevans0 (Jeremy Evans) about 5 years ago

  • Status changed from Open to Closed
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0