[#100309] How to use backport custom field — Jun Aruga <jaruga@...>
Please allow my ignorance.
9 messages
2020/10/06
[#100310] Re: How to use backport custom field
— "NARUSE, Yui" <naruse@...>
2020/10/06
IkJhY2twb3J0IGN1c3RvbSBmaWVsZCIgaXMgb25seSBhdmFpbGFibGUgZm9yIHRpY2tldHMgd2hv
[#100311] Re: How to use backport custom field
— Jun Aruga <jaruga@...>
2020/10/06
On Tue, Oct 6, 2020 at 4:44 PM NARUSE, Yui <naruse@airemix.jp> wrote:
[#100314] Re: How to use backport custom field
— "NARUSE, Yui" <naruse@...>
2020/10/06
VGhhbmsgeW91IGZvciBjb25maXJtYXRpb24uCkkgY2hlY2tlZCBhZ2FpbiBhbmQgdG8gZWRpdCBi
[#100322] Re: How to use backport custom field
— Jun Aruga <jaruga@...>
2020/10/07
On Tue, Oct 6, 2020 at 7:25 PM NARUSE, Yui <naruse@airemix.jp> wrote:
[#100326] Re: How to use backport custom field
— "NARUSE, Yui" <naruse@...>
2020/10/07
SSBhZGRlZCB5b3UgdG8gIlJlcG9ydGVyIiByb2xlIGluIHRoZSBwcm9qZWN0CgoyMDIw5bm0MTDm
[#100327] Re: How to use backport custom field
— Jun Aruga <jaruga@...>
2020/10/07
On Wed, Oct 7, 2020 at 1:42 PM NARUSE, Yui <naruse@airemix.jp> wrote:
[ruby-core:100289] [Ruby master Bug#17178] Procs with kw:def/**kw lose elements when called with a single Array
From:
matz@...
Date:
2020-10-03 08:14:20 UTC
List:
ruby-core #100289
Issue #17178 has been updated by matz (Yukihiro Matsumoto).
Status changed from Open to Closed
I think it should be as it is. It would break compatibility from Ruby2.x. It's not that big issue worh breaking.
Matz.
----------------------------------------
Bug #17178: Procs with kw:def/**kw lose elements when called with a single Array
https://bugs.ruby-lang.org/issues/17178#change-87874
* Author: Eregon (Benoit Daloze)
* Status: Closed
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* ruby -v: ruby 3.0.0dev (2020-09-18T09:12:58Z master e1cca08a6d) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
```
$ ruby -ve '{a: 1}.each_pair { |a, kw: :def| p [a,kw] }'
ruby 3.0.0dev (2020-09-18T09:12:58Z master e1cca08a6d) [x86_64-linux]
[:a, :def] # bug, should be [[1, 2], :def]
$ ruby -ve '{a: 1}.each_pair { |a, **kw| p [a,kw] }'
ruby 3.0.0dev (2020-09-18T09:12:58Z master e1cca08a6d) [x86_64-linux]
[:a, {}] # bug, should be [[1, 2], {}]
```
So the value of the key-value pair is lost and not assigned to any argument.
This seems a general problem of Proc, not just #each_pair:
```
$ ruby -e 'proc { |a, kw: :def| p [a,kw] }.call(1,2)'
[1, :def] # understandable
$ ruby -e 'proc { |a, kw: :def| p [a,kw] }.call([1,2])'
[1, :def] # bug, should be [[1, 2], :def]
$ ruby -e 'proc { |a, **kw| p [a,kw] }.call(1,2)'
[1, {}] # understandable
$ ruby -e 'proc { |a, **kw| p [a,kw] }.call([1,2])'
[1, {}] # bug, should be [[1, 2], {}]
```
--
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>