[#97678] [Ruby master Feature#16752] :private param for const_set — bughitgithub@...
Issue #16752 has been reported by bughit (bug hit).
5 messages
2020/04/02
[ruby-core:97979] [Ruby master Feature#16801] The default Struct constructor improperly handle keyword arguments
From:
jean.boussier@...
Date:
2020-04-20 14:20:42 UTC
List:
ruby-core #97979
Issue #16801 has been updated by byroot (Jean Boussier).
To clarify, what I'm trying to say is that the `"new"` method should simply forward everything to the `initialize` method no matter what. I can't see any reason for `Struct#new` to have arbitrary restrictions.
----------------------------------------
Feature #16801: The default Struct constructor improperly handle keyword arguments
https://bugs.ruby-lang.org/issues/16801#change-85208
* 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: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>