Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
marcandre opened this issue Apr 25, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@marcandre
Copy link

commented Apr 25, 2019

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.

@headius

This comment has been minimized.

Copy link
Member

commented Apr 25, 2019

Likely the same as other issues with yield + enumerator. There's still some places where we're not unwrapping properly, or unwrapping too much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.