oracle / truffleruby

A high performance implementation of the Ruby programming language, built on GraalVM.
https://www.graalvm.org/ruby/
Other
3k stars 183 forks source link

Difference in value class yielded to block in `Numeric#step` #2797

Open mostlyobvious opened 1 year ago

mostlyobvious commented 1 year ago

I'm trying to introduce truffleruby in RailsEventStore (again). Which brought me to this observed difference:

ruby -v -e "0.step(Float::INFINITY, 10) { |offset| p offset.class; break }"
truffleruby 22.3.0, like ruby 3.0.3, GraalVM CE Native [aarch64-darwin]
Float

vs.

ruby -v -e "0.step(Float::INFINITY, 10) { |offset| p offset.class; break }"
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin22]
Integer

https://ruby-doc.org/core-3.1.2/Numeric.html#method-i-step

andrykonchin commented 1 year ago

Thank you for reporting!

andrykonchin commented 1 year ago

Looks like Ruby behaves inconsistently when a block is and isn't passed. Placed an issue https://bugs.ruby-lang.org/issues/19231.

andrykonchin commented 2 months ago

Seems CRuby switched back to Integer in 3.3:

$ ruby -ve '0.step(Float::INFINITY, 10) { |offset| p offset.class; break }'
ruby 3.3.0 (2023-12-25 revision 5124f9ac75) [x86_64-darwin23]
Integer