From: milovan.zogovic@... Date: 2015-07-21T14:29:59+00:00 Subject: [ruby-core:70069] [Ruby trunk - Bug #11382] [Open] Keyword arguments nullified on inheritance Issue #11382 has been reported by Milovan Zogovic. ---------------------------------------- Bug #11382: Keyword arguments nullified on inheritance https://bugs.ruby-lang.org/issues/11382 * Author: Milovan Zogovic * Status: Open * Priority: Normal * Assignee: * ruby -v: 2.2.2 * Backport: ---------------------------------------- Here is the example: ~~~ class Parent def initialize(a: nil, b: nil, **properties) puts("parent: { a: #{a.inspect}, b: #{b.inspect}, properties: #{properties}") end end class Child < Parent def initialize(args={}) puts("child: #{args}") super end end require "yaml" Child.new(a: "A", **YAML.load("---\n:b: B\n:x: X")) # ok Child.new(a: "A", **YAML.load("---\n:b: B\n:xx: XX")) # bug: ":a" gets nullified ~~~ The output is: ~~~ child: {:a=>"A", :b=>"B", :x=>"X"} parent: { a: "A", b: "B", properties: {:x=>"X"} child: {:a=>"A", :b=>"B", :xx=>"XX"} parent: { a: "A", b: nil, properties: {:xx=>"XX"} ~~~ The only difference between first and second example is that the second one uses :xx as extra argument, while the first one uses :x. The bug will appear randomly based on the argument name. Also, this only happens when when the arguments are loaded from somewhere else (e.g. YAML.load). If i put `{ b: "B", xx: "XX" }` just anywhere in the code, the bug won't happen, which is extra weird. It works with ruby 2.1, and 2.0. -- https://bugs.ruby-lang.org/