[#92891] Question: ruby 2.7.0-preview1 also upgrades bundler to 2.1.0.pre.1? — Al Snow <jasnow@...>
Tried the new 2.7.0-preview1 upgrade to Ruby and see that bundler is also upgraded (to 2.1.0.pre.1).
5 messages
2019/05/30
[#92892] Re: Question: ruby 2.7.0-preview1 also upgrades bundler to 2.1.0.pre.1?
— SHIBATA Hiroshi <hsbt@...>
2019/05/30
Bundler 2.1.0.pree.1 is the expected version.
[ruby-core:92647] [Ruby trunk Bug#15849] Using hash as first positional argument, mixed with named arguments causes unexpected behavior
From:
jared_smartt_92@...
Date:
2019-05-14 18:39:39 UTC
List:
ruby-core #92647
Issue #15849 has been reported by jsmartt (Jared Smartt).
----------------------------------------
Bug #15849: Using hash as first positional argument, mixed with named arguments causes unexpected behavior
https://bugs.ruby-lang.org/issues/15849
* Author: jsmartt (Jared Smartt)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.4.5p335 (2018-10-18 revision 65137) [x86_64-linux]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
If the first argument of a method defaults to an empty hash, and there is another keyword argument after it, it does not set first parameter given to the first argument
For example:
``` ruby
data = {}
# This method does not modify the data hash as expected
def add_to_data(data = {}, key: 'a')
data[key] = 'value'
end
add_to_data(data)
puts data # {}
```
Trying the following produces an error:
```ruby
data = { b: 'val' }
add_to_data(data) # ERROR: unknown keyword: b (ArgumentError)
```
There are a lot of other similar combinations of this method definition that do work as expected. It appears that having a default value for that first positional argument is what causes issues; see the attached script.
---Files--------------------------------
ruby_named_param_bug.rb (1.2 KB)
--
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>