Project

General

Profile

Bug #16504

`foo(*args, &args.pop)` should pass all elements of args

Added by mame (Yusuke Endoh) 9 months ago. Updated 4 months ago.

Status:
Closed
Priority:
Normal
Target version:
-
ruby -v:
ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux]
[ruby-core:96798]

Description

https://bugs.ruby-lang.org/issues/16500?next_issue_id=16499&prev_issue_id=16501#note-7

def foo(*args)
  p args
end

# 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)

Related issues

Related to Ruby master - Bug #16500: Argument is added to both splat and last &block argumentClosedioquatix (Samuel Williams)Actions
Related to Ruby master - Bug #12860: Splatting an argument does not obey left-to-right execution orderClosedActions

Also available in: Atom PDF