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? is wrong for sequence of empty arrays #5968

Closed
buehmann opened this issue Nov 8, 2019 · 4 comments · Fixed by #6112
Closed

Enumerator#any? is wrong for sequence of empty arrays #5968

buehmann opened this issue Nov 8, 2019 · 4 comments · Fixed by #6112

Comments

@buehmann
Copy link

@buehmann buehmann commented Nov 8, 2019

Environment

$ cat jruby_bug.rb 
p [[]].any?
p [[]].to_enum.any?

Expected Behavior

$ ruby -v                      
jruby 9.2.8.0 (2.5.3) 2019-08-12 a1ac7ff OpenJDK 64-Bit Server VM 11.0.5-ea+10-post-Ubuntu-0ubuntu1 on 11.0.5-ea+10-post-Ubuntu-0ubuntu1 +jit [linux-x86_64]
$ ruby jruby_bug.rb 2>/dev/null
true
true

(same for MRI)

Actual Behavior

$ ruby -v                      
jruby 9.2.9.0 (2.5.7) 2019-10-30 458ad3e OpenJDK 64-Bit Server VM 11.0.5-ea+10-post-Ubuntu-0ubuntu1 on 11.0.5-ea+10-post-Ubuntu-0ubuntu1 +jit [linux-x86_64]
$ ruby jruby_bug.rb 2>/dev/null
true
false

Discovered through rubocop/rubocop#7489

@ahorek
Copy link
Contributor

@ahorek ahorek commented Nov 12, 2019

bisected to this change d16918b

here's a different example that better explains the behavior

actual

 [[]].to_enum.take(1)
=> [nil]

expected

 [[]].to_enum.take(1)
=> [[]]

cc @kares

@kares
Copy link
Member

@kares kares commented Nov 13, 2019

oh nice, so we got a regression - seems like the test coverage isn't perfect.

was basically trying to increase compatibility (there's some more commits involved with Enumerator work in 9.2.9 than the one @ahorek bisected for us) and fix some long standing bugs.

hopefully we can fix this (pathological) case without regressing other stuff we started passing in 9.2.9

kares added a commit to kares/jruby that referenced this issue Dec 28, 2019
... `[[]].to_enum.take(1)` regressed in 9.2.9 (jrubyGH-5968)
but the required signature was incorrect along the way
@kares kares added this to the JRuby 9.2.10.0 milestone Dec 28, 2019
@kares kares closed this as completed Dec 28, 2019
@koic
Copy link

@koic koic commented Mar 6, 2020

Hi @kares. This issue doesn't seem to be resolved in JRuby 9.2.10.0 and 9.2.11.0.

% cat jruby_bug.rb
p [[]].any?
p [[]].to_enum.any?

JRuby 9.2.8.0

% ruby -v
jruby 9.2.8.0 (2.5.3) 2019-08-12 a1ac7ff Java HotSpot(TM) 64-Bit Server VM 25.5-b02 on 1.8.0_05-b13 +jit [darwin-x86_64]
% ruby jruby_bug.rb
true
true

JRuby 9.2.10.0

% ruby -v
jruby 9.2.10.0 (2.5.7) 2020-02-18 fffffff Java HotSpot(TM) 64-Bit Server VM 25.5-b02 on 1.8.0_05-b13 +jit [darwin-x86_64]
% ruby jruby_bug.rb
true
false

JRuby 9.2.11.0

% ruby -v
jruby 9.2.11.0 (2.5.7) 2020-03-02 612d7a05a6 Java HotSpot(TM) 64-Bit Server VM 25.5-b02 on 1.8.0_05-b13 +jit [darwin-x86_64]
% ruby jruby_bug.rb
true
false

@enebo enebo reopened this Mar 6, 2020
@enebo enebo removed this from the JRuby 9.2.10.0 milestone Mar 6, 2020
@enebo enebo added this to the JRuby 9.3.0.0 milestone Mar 6, 2020
@headius headius removed this from the JRuby 9.3.0.0 milestone Jun 16, 2020
@headius headius added this to the JRuby 9.2.12.0 milestone Jun 16, 2020
@headius
Copy link
Member

@headius headius commented Jun 16, 2020

Retargeted to 9.2.12. See #6285.

koic added a commit to koic/rubocop that referenced this issue Jul 20, 2020
This reverts commit 7743366.

jruby/jruby#5968 has been solved by JRuby 9.2.12.0.
bbatsov pushed a commit to rubocop/rubocop that referenced this issue Jul 20, 2020
This reverts commit 7743366.

jruby/jruby#5968 has been solved by JRuby 9.2.12.0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants