[#68478] Looking for MRI projects for Ruby Google Summer of Code 2015 — Tony Arcieri <bascule@...>

Hi ruby-core,

10 messages 2015/03/10

[ruby-core:68590] [Ruby trunk - Bug #10994] [Open] Inconsistent behavior when mixing optional argument and keyword splat

From: ruipserra@...
Date: 2015-03-21 17:28:59 UTC
List: ruby-core #68590
Issue #10994 has been reported by Rui Serra.

----------------------------------------
Bug #10994: Inconsistent behavior when mixing optional argument and keyword splat
https://bugs.ruby-lang.org/issues/10994

* Author: Rui Serra
* Status: Open
* Priority: Normal
* Assignee: 
* ruby -v: ruby 2.2.1p85 (2015-02-26 revision 49769) [x86_64-darwin13]
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN
----------------------------------------
The following code produces inconsistent behavior:

```
def foo(x=nil, **kw) 
  x 
end

h = { "a" => 1 }

foo(h)                  # => {"a"=>1} 
foo(h).equal?(h)        # => false
foo(h, y: 1).equal?(h)  # => true
```

It seems that in this very specific case, foo is returning a copy of h instead of returning h itself. I guess this is an edge case in the keyword extraction process.

Thank you for your time.



-- 
https://bugs.ruby-lang.org/

In This Thread

Prev Next