Project

General

Profile

Actions

Backport #8735

closed

Enumerator::Lazy#zip behaves differently from Enumerable#zip when yield with non-single argument

Added by kachick (Kenichi Kamiya) over 10 years ago. Updated over 10 years ago.


Description

=begin
Is this intended?

obj = Object.new
def obj.each
yield
yield 1, 2
end

obj.to_enum.zip(obj.to_enum) #=> [[nil, nil],
# [[1, 2], [1, 2]]]

obj.to_enum.lazy.zip(obj.to_enum).force #=> [[false, nil],
# [1, [1, 2]]]
=end

Updated by nobu (Nobuyoshi Nakada) over 10 years ago

  • Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN to 1.9.3: DONTNEED, 2.0.0: REQUIRED
Actions #2

Updated by nobu (Nobuyoshi Nakada) over 10 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r42450.
Kenichi, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


enumerator.c: fix non-single argument

  • enumerator.c (lazy_zip_func): fix non-single argument. fix
    out-of-bound access and pack multiple yielded values.
    [ruby-core:56383] [Bug #8735]

Updated by phluid61 (Matthew Kerwin) over 10 years ago

I believe the issue is here:
https://github.com/ruby/ruby/blob/trunk/enumerator.c#L1703

I'd write a patch for the cases argc==0{Qnil} or argc>1{rb_ary_new4(...)}
but I'm away from my computer right now.

Sent from my phone, so excuse the typos.
On Aug 5, 2013 9:30 PM, "kachick (Kenichi Kamiya)"
wrote:

Issue #8735 has been reported by kachick (Kenichi Kamiya).


Bug #8735: Enumerator::Lazy#zip behaves differently from Enumerable#zip
when yield with non-single argument
https://bugs.ruby-lang.org/issues/8735

Author: kachick (Kenichi Kamiya)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby -v ruby 2.1.0dev (2013-08-05 trunk 42385) [i686-linux]
Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN

=begin
Is this intended?

obj = Object.new
def obj.each
yield
yield 1, 2
end

obj.to_enum.zip(obj.to_enum) #=> [[nil, nil],
# [[1, 2], [1, 2]]]

obj.to_enum.lazy.zip(obj.to_enum).force #=> [[false, nil],
# [1, [1, 2]]]
=end

--
http://bugs.ruby-lang.org/

Actions #5

Updated by nagachika (Tomoyuki Chikanaga) over 10 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby master to Backport200
  • Status changed from Closed to Assigned
  • Assignee set to nagachika (Tomoyuki Chikanaga)
Actions #6

Updated by nagachika (Tomoyuki Chikanaga) over 10 years ago

  • Status changed from Assigned to Closed

This issue was solved with changeset r42922.
Kenichi, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 42450: [Backport #8735]

* enumerator.c (lazy_zip_func): fix non-single argument.  fix
  out-of-bound access and pack multiple yielded values.
  [ruby-core:56383] [Bug #8735]
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0