[ruby-core:96820] [Ruby master Bug#16504] `foo(*args, &args.pop)` should pass all elements of args
From:
mame@...
Date:
2020-01-12 23:44:36 UTC
List:
ruby-core #96820
Issue #16504 has been updated by mame (Yusuke Endoh).
Okay, I'll ask matz which is right. But I believe that the 2.6 and current behavior is wrong because Ruby has a principle of left-to-right evaluation. Actually, `foo(*ary, ary.pop)` was changed between 2.1 and 2.2; 2.2 and later duplicate the last argument. And what do you think about `foo(*ary, 42, &ary.pop)`?
----------------------------------------
Bug #16504: `foo(*args, &args.pop)` should pass all elements of args
https://bugs.ruby-lang.org/issues/16504#change-83814
* Author: mame (Yusuke Endoh)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
https://bugs.ruby-lang.org/issues/16500?next_issue_id=16499&prev_issue_id=16501#note-7
```
# in 2.7
args = [1, 2, -> {}]; foo( *args, &args.pop) #=> passes [1, 2] (bug; [1, 2, ->{}] is expected)
args = [1, 2, -> {}]; foo(0, *args, &args.pop) #=> passes [0, 1, 2, ->{}] (good)
```
--
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>