truffleruby icon indicating copy to clipboard operation
truffleruby copied to clipboard

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

Open mostlyobvious opened this issue 3 years ago • 3 comments

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

mostlyobvious avatar Nov 29 '22 12:11 mostlyobvious

Thank you for reporting!

andrykonchin avatar Nov 29 '22 13:11 andrykonchin

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

andrykonchin avatar Dec 13 '22 15:12 andrykonchin

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

andrykonchin avatar Jun 21 '24 11:06 andrykonchin