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

`slice_after` does not work on lazy Enumerators #5853

Closed
ilikeorangutans opened this issue Aug 29, 2019 · 3 comments
Closed

`slice_after` does not work on lazy Enumerators #5853

ilikeorangutans opened this issue Aug 29, 2019 · 3 comments
Milestone

Comments

@ilikeorangutans
Copy link
Contributor

@ilikeorangutans ilikeorangutans commented Aug 29, 2019

Environment

Provide at least:

  • jruby 9.2.6.0 (2.5.3) 2019-02-11 15ba00b OpenJDK 64-Bit Server VM 25.222-b10 on 1.8.0_222-b10 +jit [darwin-x86_64]
  • Darwin Jakobs-MacBook-Pro-2.local 18.7.0 Darwin Kernel Version 18.7.0: Tue Aug 20 16:57:14 PDT 2019; root:xnu-4903.271.2~2/RELEASE_X86_64 x86_64

Other relevant info you may wish to add:

  • just in irb, no gems loaded

Expected Behavior

In mri ruby I can use slice_after on a lazy enumerator to slice up a stream of elements into a grouped enumerator:

irb(main):001:0> %w(a x b x c).lazy.slice_after(/x/).to_a
=> [["a", "x"], ["b", "x"], ["c"]]

Actual Behavior

irb(main):005:0> %w(a x b x c).lazy.slice_after(/x/).to_a
Traceback (most recent call last):
       10: from /opt/rubies/jruby-9.2.6.0/bin/irb:13:in `<main>'
        9: from org/jruby/RubyKernel.java:1179:in `catch'
        8: from org/jruby/RubyKernel.java:1179:in `catch'
        7: from org/jruby/RubyKernel.java:1411:in `loop'
        6: from org/jruby/RubyKernel.java:1047:in `eval'
        5: from (irb):5:in `evaluate'
        4: from org/jruby/RubyEnumerable.java:461:in `to_a'
        3: from org/jruby/RubyEnumerator.java:326:in `each'
        2: from uri:classloader:/jruby/kernel/enumerator.rb:64:in `slice_after'
        1: from uri:classloader:/jruby/kernel/enumerable.rb:37:in `slice_after'
ArgumentError (cannot pass both filter argument and block)

Interestingly this only seems to affect lazy enumerators. With a non-lazy enumerator it works as expected:

irb(main):002:0> %w(a x b x c).slice_after(/x/).to_a
=> [["a", "x"], ["b", "x"], ["c"]]
@enebo enebo added this to the JRuby 9.2.9.0 milestone Aug 29, 2019
@enebo

This comment has been minimized.

Copy link
Member

@enebo enebo commented Aug 29, 2019

@ilikeorangutans this is working on master so it should be out in 9.2.9.0.

@enebo enebo closed this Aug 29, 2019
@ilikeorangutans

This comment has been minimized.

Copy link
Contributor Author

@ilikeorangutans ilikeorangutans commented Aug 29, 2019

@enebo Oh this is great news. Was there an issue that I missed?

@enebo

This comment has been minimized.

Copy link
Member

@enebo enebo commented Aug 29, 2019

@ilikeorangutans I don't think so but there was some recent work on Enumerable/Enumerator which fixed some ruby/specs recently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.