Project

General

Profile

Bug #14495

Enumerator::Lazy#uniq invalid state

Added by chopraanmol1 (Anmol Chopra) over 1 year ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 2.5.0preview1 (2017-10-10 trunk 60153) [x86_64-linux]
[ruby-core:85646]

Description

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

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

Associated revisions

Revision 62731
Added by nobu (Nobuyoshi Nakada) over 1 year ago

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@rocketbox.in

Revision 62735
Added by nobu (Nobuyoshi Nakada) over 1 year ago

test_enumerator.rb: duplicate assertions

  • test/ruby/test_enumerator.rb (test_uniq): remove assertions which ared duplicate of lazy enumerator tests in test_lazy_enumerator.rb.

Revision bb853294
Added by nagachika (Tomoyuki Chikanaga) about 1 year ago

merge revision(s) 62731,62735: [Backport #14495]

    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@rocketbox.in>

    test_enumerator.rb: duplicate assertions

    * test/ruby/test_enumerator.rb (test_uniq): remove assertions
      which ared duplicate of lazy enumerator tests in
      test_lazy_enumerator.rb.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@63824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 63824
Added by nagachika (Tomoyuki Chikanaga) about 1 year ago

merge revision(s) 62731,62735: [Backport #14495]

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@rocketbox.in>

test_enumerator.rb: duplicate assertions

* test/ruby/test_enumerator.rb (test_uniq): remove assertions
  which ared duplicate of lazy enumerator tests in
  test_lazy_enumerator.rb.

Revision 7d957281
Added by usa (Usaku NAKAMURA) about 1 year ago

merge revision(s) 62731,62735: [Backport #14495]

    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@rocketbox.in>

    test_enumerator.rb: duplicate assertions

    * test/ruby/test_enumerator.rb (test_uniq): remove assertions
      which ared duplicate of lazy enumerator tests in
      test_lazy_enumerator.rb.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@64558 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 64558
Added by usa (Usaku NAKAMURA) about 1 year ago

merge revision(s) 62731,62735: [Backport #14495]

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@rocketbox.in>

test_enumerator.rb: duplicate assertions

* test/ruby/test_enumerator.rb (test_uniq): remove assertions
  which ared duplicate of lazy enumerator tests in
  test_lazy_enumerator.rb.

History

Updated by Eregon (Benoit Daloze) over 1 year ago

Should this be backported?

Updated by chopraanmol1 (Anmol Chopra) over 1 year ago

Yes, to 2.4 and 2.5

#4

Updated by nagachika (Tomoyuki Chikanaga) about 1 year ago

  • Backport changed from 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN to 2.3: UNKNOWN, 2.4: REQUIRED, 2.5: REQUIRED

Updated by nagachika (Tomoyuki Chikanaga) about 1 year ago

  • Backport changed from 2.3: UNKNOWN, 2.4: REQUIRED, 2.5: REQUIRED to 2.3: UNKNOWN, 2.4: REQUIRED, 2.5: DONE

ruby_2_5 r63824 merged revision(s) 62731,62735.

#6

Updated by nagachika (Tomoyuki Chikanaga) about 1 year ago

  • Status changed from Open to Closed

Applied in changeset ruby_2_5|r63824.


merge revision(s) 62731,62735: [Backport #14495]

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@rocketbox.in>

test_enumerator.rb: duplicate assertions

* test/ruby/test_enumerator.rb (test_uniq): remove assertions
  which ared duplicate of lazy enumerator tests in
  test_lazy_enumerator.rb.

Updated by usa (Usaku NAKAMURA) about 1 year ago

  • Backport changed from 2.3: UNKNOWN, 2.4: REQUIRED, 2.5: DONE to 2.3: UNKNOWN, 2.4: DONE, 2.5: DONE

ruby_2_4 r64558 merged revision(s) 62731,62735.

Also available in: Atom PDF