Issue #10315 has been updated by Nobuyoshi Nakada.

Status changed from Open to Closed
% Done changed from 0 to 100

Applied in changeset r47877.

----------
parse.y: precedence of duplicated keys

* parse.y (assocs): concatenate splatted literal hashes.  the
  former key has precedence even if duplicated literal keys
  follow.  [ruby-core:65368] [Bug #10315]

----------------------------------------
Bug #10315: Override policy for duplicated keywords
https://bugs.ruby-lang.org/issues/10315#change-49348

* Author: Koichi Sasada
* Status: Closed
* Priority: Normal
* Assignee: Yukihiro Matsumoto
* Category: core
* Target version: current: 2.2.0
* ruby -v: 2.2-2.0
* Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN
----------------------------------------

```ruby
p({k1: 'a', k1: 'b'})         #=> {:k1=>"b"}
p({k1: 'a'}.merge({k1: 'b'})) #=> {:k1=>"b"}
p(k1: 'a', k1: 'b')           #=> {:k1=>"b"}
p(k1: 'a', **{k1: 'b'})       #=> {:k1=>"a"}
```

IMO the last case should also output {:k1=>"b"}.

Nobu said that we should show warning for such duplication (especially for 1st and 3rd cases) because we can detect duplication while parsing/compiling.




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