Issue #14495 has been updated by chopraanmol1 (Anmol Chopra).


Yes, to 2.4 and 2.5

----------------------------------------
Bug #14495: Enumerator::Lazy#uniq invalid state
https://bugs.ruby-lang.org/issues/14495#change-71257

* Author: chopraanmol1 (Anmol Chopra)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.5.0preview1 (2017-10-10 trunk 60153) [x86_64-linux]
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------

Currently

~~~ ruby
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

~~~ ruby
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
 => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] 
~~~


Solution **Enumerator::Lazy#uniq**'s hash should be accessed from yielder memo



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

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>