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

Begin-less range with step not returning the correct class #2514

Closed
ccocchi opened this issue Oct 24, 2021 · 2 comments · Fixed by #2516
Closed

Begin-less range with step not returning the correct class #2514

ccocchi opened this issue Oct 24, 2021 · 2 comments · Fixed by #2516
Assignees
Milestone

Comments

@ccocchi
Copy link
Contributor

ccocchi commented Oct 24, 2021

Hello,

While working on Array#slice with Enumerator::ArithmeticSequence (for 3.0 support), I found a discrepancy between Cruby 3.0.1 and truffleruby 22.0 :

# ruby 3.0.1p64
irb(main):018:0> (..0).step(1).class
=> Enumerator::ArithmeticSequence

vs

# truffleruby 22.0.0-dev-59020ff8, like ruby 3.0.2, Interpreted JVM [x86_64-darwin]
irb(main):002:0> (..0).step(1).class
=> Enumerator

The problem seems to only occur when dealing with begin-less range, the method #step returns a Enumerator::ArithmeticSequence for other type of ranges.

@eregon
Copy link
Member

eregon commented Oct 25, 2021

Thank you for the report, it looks like it works for endless ranges but not beginless ranges.

If you'd like to fix this yourself with a PR then please go ahead, I think it is fairly straightforward (in Range#step_internal).
If not please reply here and we'll try to take care of it.

@ccocchi
Copy link
Contributor Author

ccocchi commented Oct 27, 2021

Made a PR for it 🙂

@eregon eregon added this to the 22.0.0 milestone Oct 29, 2021
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.

2 participants