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::Lazy missing filter_map and with_index methods #2356

Closed
ivoanjo opened this issue May 25, 2021 · 4 comments
Closed

Enumerator::Lazy missing filter_map and with_index methods #2356

ivoanjo opened this issue May 25, 2021 · 4 comments
Assignees
Milestone

Comments

@ivoanjo
Copy link
Contributor

ivoanjo commented May 25, 2021

Hello, hello 👋

I'm again spending a few minutes trying to get @DataDog's ddtrace gem specs going with TruffleRuby and I've noticed that Enumerator::Lazy is missing a few more methods (beyond those fixed in #2273), which forces lazy enumerators to become eager (non-lazy). The impact can be that, of course, if you do that with an infinite enumerator, the app will break (and in general it breaks the expected semantics).

In particular, the following are still not lazy on TruffleRuby:

  • filter_map
# truffleruby 21.1.0, like ruby 2.7.2, GraalVM CE Native [x86_64-darwin]
[10] pry(main)> [1].lazy.filter_map(&:zero?)
=> []
# ruby 2.7.3p183 (2021-04-05 revision 6847ee089d) [x86_64-darwin19]
[7] pry(main)> [1].lazy.filter_map(&:zero?)
=> #<Enumerator::Lazy: ...>
  • with_index
# truffleruby 21.1.0, like ruby 2.7.2, GraalVM CE Native [x86_64-darwin]
[19] pry(main)> [1].lazy.with_index(&:+)
=> [1]
# ruby 2.7.3p183 (2021-04-05 revision 6847ee089d) [x86_64-darwin19]
[14] pry(main)> [1].lazy.with_index(&:+)
=> #<Enumerator::Lazy: ...>
@eregon
Copy link
Member

eregon commented May 25, 2021

Thank you for the report. @bjfish Could you look at this?

@eregon
Copy link
Member

eregon commented May 26, 2021

As a note, it seems both of these methods are new as of Ruby 2.7.

@bjfish
Copy link
Contributor

bjfish commented Jun 7, 2021

These methods have been implemented at:
3c68160
e6e7a0e

@bjfish bjfish closed this as completed Jun 7, 2021
@ivoanjo
Copy link
Contributor Author

ivoanjo commented Jun 8, 2021

Thanks @bjfish for looking into this 🙇

@eregon eregon added this to the 21.2.0 milestone Jun 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants