[ruby-cvs:69883] nobu:r62731 (trunk): Bug Fix Enumerator::Lazy#uniq state for multiple call

nobu at ruby-lang.org nobu at ruby-lang.org
Tue Mar 13 10:00:08 JST 2018


nobu	2018-03-13 10:00:08 +0900 (Tue, 13 Mar 2018)

  New Revision: 62731

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62731

  Log:
    Bug Fix Enumerator::Lazy#uniq state for multiple call
    
    * enumerator.c (lazy_uniq_i): create new hash for each calls.
      [Fix GH-1820]
    
    Currently
    
    2.5.0-preview1 :001 > arr = (0..100).lazy.uniq{|i| i % 10}
     => #<Enumerator::Lazy: #<Enumerator::Lazy: 0..100>:uniq>
    2.5.0-preview1 :002 > arr.to_a
     => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
    2.5.0-preview1 :003 > arr.to_a
     => []
    
    Expected
    
    arr.to_a to always return same output
    
    From: Anmol Chopra <anmolchopra at rocketbox.in>

  Modified files:
    trunk/enumerator.c
    trunk/spec/ruby/core/enumerator/lazy/uniq_spec.rb
    trunk/test/ruby/test_enumerator.rb
    trunk/test/ruby/test_lazy_enumerator.rb


More information about the ruby-cvs mailing list