ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:96798] [Ruby master Bug#16504] `foo(*args, &args.pop)` should pass all elements of args
       [not found] <redmine.issue-16504.20200112004751@ruby-lang.org>
@ 2020-01-12  0:47 ` mame
  2020-01-12  0:52 ` [ruby-core:96799] " mame
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: mame @ 2020-01-12  0:47 UTC (permalink / raw)
  To: ruby-core

Issue #16504 has been reported by mame (Yusuke Endoh).

----------------------------------------
Bug #16504: `foo(*args, &args.pop)` should pass all elements of args
https://bugs.ruby-lang.org/issues/16504

* 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/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ruby-core:96799] [Ruby master Bug#16504] `foo(*args, &args.pop)` should pass all elements of args
       [not found] <redmine.issue-16504.20200112004751@ruby-lang.org>
  2020-01-12  0:47 ` [ruby-core:96798] [Ruby master Bug#16504] `foo(*args, &args.pop)` should pass all elements of args mame
@ 2020-01-12  0:52 ` mame
  2020-01-12 16:37 ` [ruby-core:96806] " eregontp
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: mame @ 2020-01-12  0:52 UTC (permalink / raw)
  To: ruby-core

Issue #16504 has been updated by mame (Yusuke Endoh).


https://github.com/ruby/ruby/pull/2833

----------------------------------------
Bug #16504: `foo(*args, &args.pop)` should pass all elements of args
https://bugs.ruby-lang.org/issues/16504#change-83791

* 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/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ruby-core:96806] [Ruby master Bug#16504] `foo(*args, &args.pop)` should pass all elements of args
       [not found] <redmine.issue-16504.20200112004751@ruby-lang.org>
  2020-01-12  0:47 ` [ruby-core:96798] [Ruby master Bug#16504] `foo(*args, &args.pop)` should pass all elements of args mame
  2020-01-12  0:52 ` [ruby-core:96799] " mame
@ 2020-01-12 16:37 ` eregontp
  2020-01-12 23:44 ` [ruby-core:96820] " mame
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: eregontp @ 2020-01-12 16:37 UTC (permalink / raw)
  To: ruby-core

Issue #16504 has been updated by Eregon (Benoit Daloze).


What's the definition of `foo` here?

I believe the previous behavior is the block expression gets evaluated before the rest of the arguments.
We should decide and clarify if the block or positional arguments are evaluated first.

If I see `foo(*args, &args.pop)` I would expect no duplicated arguments.
I believe that's the previous and more intuitive behavior.
I'd be happy if we can warn it though, because that code is really unreadable.

`foo(*args, &args.last)` should be used if wanting to pass the last argument both as block and last positional.

----------------------------------------
Bug #16504: `foo(*args, &args.pop)` should pass all elements of args
https://bugs.ruby-lang.org/issues/16504#change-83801

* 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/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ruby-core:96820] [Ruby master Bug#16504] `foo(*args, &args.pop)` should pass all elements of args
       [not found] <redmine.issue-16504.20200112004751@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2020-01-12 16:37 ` [ruby-core:96806] " eregontp
@ 2020-01-12 23:44 ` mame
  2020-01-13  0:01 ` [ruby-core:96821] " mame
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 7+ messages in thread
From: mame @ 2020-01-12 23:44 UTC (permalink / raw)
  To: ruby-core

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/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ruby-core:96821] [Ruby master Bug#16504] `foo(*args, &args.pop)` should pass all elements of args
       [not found] <redmine.issue-16504.20200112004751@ruby-lang.org>
                   ` (3 preceding siblings ...)
  2020-01-12 23:44 ` [ruby-core:96820] " mame
@ 2020-01-13  0:01 ` mame
  2020-01-13 13:21 ` [ruby-core:96825] " eregontp
  2020-01-13 14:27 ` [ruby-core:96826] " ruby-core
  6 siblings, 0 replies; 7+ messages in thread
From: mame @ 2020-01-13  0:01 UTC (permalink / raw)
  To: ruby-core

Issue #16504 has been updated by mame (Yusuke Endoh).


I spent an hour to find the ticket: https://bugs.ruby-lang.org/issues/12860

----------------------------------------
Bug #16504: `foo(*args, &args.pop)` should pass all elements of args
https://bugs.ruby-lang.org/issues/16504#change-83817

* 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/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ruby-core:96825] [Ruby master Bug#16504] `foo(*args, &args.pop)` should pass all elements of args
       [not found] <redmine.issue-16504.20200112004751@ruby-lang.org>
                   ` (4 preceding siblings ...)
  2020-01-13  0:01 ` [ruby-core:96821] " mame
@ 2020-01-13 13:21 ` eregontp
  2020-01-13 14:27 ` [ruby-core:96826] " ruby-core
  6 siblings, 0 replies; 7+ messages in thread
From: eregontp @ 2020-01-13 13:21 UTC (permalink / raw)
  To: ruby-core

Issue #16504 has been updated by Eregon (Benoit Daloze).


Agreed left-to-right would be far more consistent.

We just need to be aware that whoever writes `foo(*args, &args.pop)` probably expects no duplication (so they would disagree on "bug" probably).
But such code deserves to be clearer IMHO.

----------------------------------------
Bug #16504: `foo(*args, &args.pop)` should pass all elements of args
https://bugs.ruby-lang.org/issues/16504#change-83823

* 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/

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [ruby-core:96826] [Ruby master Bug#16504] `foo(*args, &args.pop)` should pass all elements of args
       [not found] <redmine.issue-16504.20200112004751@ruby-lang.org>
                   ` (5 preceding siblings ...)
  2020-01-13 13:21 ` [ruby-core:96825] " eregontp
@ 2020-01-13 14:27 ` ruby-core
  6 siblings, 0 replies; 7+ messages in thread
From: ruby-core @ 2020-01-13 14:27 UTC (permalink / raw)
  To: ruby-core

Issue #16504 has been updated by marcandre (Marc-Andre Lafortune).


mame (Yusuke Endoh) wrote:
> 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.

For sure current behavior is wrong and left-to-right evaluation must be observed.

----------------------------------------
Bug #16504: `foo(*args, &args.pop)` should pass all elements of args
https://bugs.ruby-lang.org/issues/16504#change-83824

* 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/

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-01-13 14:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <redmine.issue-16504.20200112004751@ruby-lang.org>
2020-01-12  0:47 ` [ruby-core:96798] [Ruby master Bug#16504] `foo(*args, &args.pop)` should pass all elements of args mame
2020-01-12  0:52 ` [ruby-core:96799] " mame
2020-01-12 16:37 ` [ruby-core:96806] " eregontp
2020-01-12 23:44 ` [ruby-core:96820] " mame
2020-01-13  0:01 ` [ruby-core:96821] " mame
2020-01-13 13:21 ` [ruby-core:96825] " eregontp
2020-01-13 14:27 ` [ruby-core:96826] " ruby-core

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).