Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Enumerator#any? and yield(*[[]]) bug #5710

@marcandre

Description

@marcandre

Environment

$ ruby -v
jruby 9.2.8.0-SNAPSHOT (2.5.3) 2019-04-25 9477784 Java HotSpot(TM) 64-Bit Server VM 25.102-b14 on 1.8.0_102-b14 +jit [darwin-x86_64]

Bug

class Foo
  def each
    return to_enum :each unless block_given?
    x = [[]]
    yield(*x)
  end
end
enum = Foo.new.each
p enum.to_a  # => [[]], ok
p enum.any?  # => false, should be true

Replacing the yield(*x) with yield(x[0]) circumvents the bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions