Project

General

Profile

Bug #2053

`for` No Longer Splats When RHS Returns More Values Than LHS Expects

Added by runpaint (Run Paint Run Run) over 10 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Target version:
ruby -v:
ruby 1.9.2dev (2009-09-05 trunk 24762) [i686-linux]
Backport:
[ruby-core:25414]

Description

=begin
$ cat /tmp/for.rb
class OFor
def each
1,2,3], [4,5,6.each do |a|
yield(a[0],a[1],a[2])
end
end
end

o = OFor.new
qs = []
for q in o
qs << q
end
p qs
p q

$ ruby8 -v /tmp/for.rb
ruby 1.8.8dev (2009-09-04) [i686-linux]
/tmp/for.rb:11: warning: multiple values for a block parameter (3 for 1)
from /tmp/for.rb:4
/tmp/for.rb:11: warning: multiple values for a block parameter (3 for 1)
from /tmp/for.rb:4
1, 2, 3], [4, 5, 6
[4, 5, 6]

$ ruby -v /tmp/for.rb
ruby 1.9.2dev (2009-09-05 trunk 24762) [i686-linux]
[1, 4]
4
=end

History

#1

Updated by yugui (Yuki Sonoda) over 10 years ago

  • Assignee set to matz (Yukihiro Matsumoto)
  • Priority changed from Normal to 3
  • Target version set to 1.9.2

=begin

=end

#2

Updated by nobu (Nobuyoshi Nakada) over 10 years ago

=begin
Hi,

At Sun, 6 Sep 2009 02:17:17 +0900,
Run Paint Run Run wrote in [ruby-core:25414]:

$ cat /tmp/for.rb
class OFor
def each
1,2,3], [4,5,6.each do |a|
yield(a[0],a[1],a[2])
end
end
end

o = OFor.new
qs = []
for q in o
qs << q
end
p qs
p q

It should be an intentional change, I think.

--
Nobu Nakada

=end

#3

Updated by runpaint (Run Paint Run Run) over 10 years ago

=begin
Thanks, nobu. I've updated the spec. Don't leave this ticket open on my account. :-)
=end

#4

Updated by nobu (Nobuyoshi Nakada) over 10 years ago

  • Status changed from Open to Closed

=begin

=end

Also available in: Atom PDF