Bug #7706

Lazy#zip should not call `lazy`

Added by Marc-Andre Lafortune over 1 year ago. Updated about 1 year ago.

[ruby-core:51472]
Status:Closed
Priority:Normal
Assignee:Marc-Andre Lafortune
Category:core
Target version:2.0.0
ruby -v:r38825 Backport:

Description

Current implementation of Lazy#zip has problems:

1) calls lazy when this is not excepted, necessary nor documented. Any reason to not call each instead?
2) calls lazy without checking previously for type:

[1].lazy.zip(42) # =>NoMethodError: undefined method `lazy' for 42:Fixnum

# expected same as [1].zip(42), i.e. a TypeError

3) inefficient in the case where all arguments are arrays

I'll address these when I get a chance. I don't understand why lazy is called instead of each though. Anyone?

Associated revisions

Revision 38925
Added by Marc-Andre Lafortune about 1 year ago

  • enumerator.c: Optimize Lazy#zip when passed only arrays [Bug #7706]

Revision 38926
Added by Marc-Andre Lafortune about 1 year ago

  • enumerator.c (lazy_zip): raise error for bad arguments [Bug #7706]

Revision 38927
Added by Marc-Andre Lafortune about 1 year ago

  • enum.c (enum_zip): Fix error message

  • array.c (take_items): Same, for Array#zip
    [Bug #7706]

History

#1 Updated by Marc-Andre Lafortune about 1 year ago

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

This issue was solved with changeset r38925.
Marc-Andre, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • enumerator.c: Optimize Lazy#zip when passed only arrays [Bug #7706]

Also available in: Atom PDF