From: jean.boussier@... Date: 2020-04-20T14:16:12+00:00 Subject: [ruby-core:97978] [Ruby master Feature#16801] The default Struct constructor improperly handle keyword arguments Issue #16801 has been updated by byroot (Jean Boussier). @jeremyevans0 I'm afraid I don't understand what you are referring to: 2.7.1: ``` $ ruby -v ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin19] $ ruby --disable-gems -e 'p Struct.new(:hash_value).new(hash_key: 1)' #1}> ``` My patch: ``` $ ./ruby -v ruby 2.8.0dev (2020-04-20T09:16:19Z struct-new-keyword 08d8195ff8) [x86_64-darwin19] $ ./ruby --disable-gems -e 'p Struct.new(:hash_value).new(hash_key: 1)' #1}> ``` ---------------------------------------- Feature #16801: The default Struct constructor improperly handle keyword arguments https://bugs.ruby-lang.org/issues/16801#change-85207 * Author: byroot (Jean Boussier) * Status: Open * Priority: Normal ---------------------------------------- Reproduction script: ```ruby Field = Struct.new(:value) do def initialize(value, keyword: false) super(value) @keyword = keyword end end Field.new(1, keyword: true) ``` ``` /tmp/kw.rb:8: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call /tmp/kw.rb:2: warning: The called method `initialize' is defined here ``` This can be worked around with `keyword_init: true`, but I see no reason why `Struct` couldn't properly handle keyword arguments in it's default constructor. I have a patch for this: https://github.com/ruby/ruby/pull/3045 however I had to modify a test that was explicitly expecting that warning, so maybe I'm missing something. -- https://bugs.ruby-lang.org/ Unsubscribe: