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

Array#pack('g') failure with bignum #2504

Closed
djberg96 opened this issue Oct 16, 2021 · 3 comments
Closed

Array#pack('g') failure with bignum #2504

djberg96 opened this issue Oct 16, 2021 · 3 comments
Assignees
Milestone

Comments

@djberg96
Copy link
Contributor

truffleruby 21.2.0, like ruby 2.7.3, GraalVM CE Native [x86_64-darwin]

irb(main):001:0> n = 2**63
=> 9223372036854775808
irb(main):002:0> [n].pack('g')
Traceback (most recent call last):
	from /Users/dberger/.rbenv/versions/truffleruby-21.2.0/bin/irb:42:in `<main>'
	from <internal:core> core/kernel.rb:400:in `load'
	from <internal:core> core/kernel.rb:400:in `load'
	from /Users/dberger/.rbenv/versions/truffleruby-21.2.0/lib/gems/gems/irb-1.3.3/exe/irb:11:in `<top (required)>'
	from <internal:core> core/throw_catch.rb:36:in `catch'
	from <internal:core> core/throw_catch.rb:36:in `catch'
	from <internal:core> core/kernel.rb:437:in `loop'
	from <internal:core> core/kernel.rb:325:in `eval'
	from (irb):2:in `<top (required)>'
(irb):2:in `pack': TruffleRuby doesn't have a case for the org.truffleruby.core.format.convert.ToDoubleNodeGen node with values of type org.truffleruby.core.numeric.RubyBignum (TypeError)
	from org.truffleruby.core.format.convert.ToDoubleNodeGen.executeAndSpecialize(ToDoubleNodeGen.java:92)
	from org.truffleruby.core.format.convert.ToDoubleNodeGen.executeToDouble(ToDoubleNodeGen.java:40)
	from org.truffleruby.core.format.read.array.ReadDoubleNode.read(ReadDoubleNode.java:40)
	from org.truffleruby.core.format.read.array.ReadDoubleNodeGen.executeAndSpecialize(ReadDoubleNodeGen.java:97)
	from org.truffleruby.core.format.read.array.ReadDoubleNodeGen.execute(ReadDoubleNodeGen.java:62)
	from org.truffleruby.core.format.convert.ToFloatNodeGen.execute(ToFloatNodeGen.java:27)
	from org.truffleruby.core.format.convert.ReinterpretAsLongNodeGen.execute(ReinterpretAsLongNodeGen.java:27)
	from org.truffleruby.core.format.convert.Integer32BigToBytesNodeGen.execute(Integer32BigToBytesNodeGen.java:27)
	from org.truffleruby.core.format.write.bytes.WriteBytesNodeGen.execute(WriteBytesNodeGen.java:26)
	from org.truffleruby.core.format.FormatRootNode.execute(FormatRootNode.java:60)
	from org.graalvm.compiler.truffle.runtime.OptimizedCallTarget.executeRootNode(OptimizedCallTarget.java:632)
@eregon
Copy link
Member

eregon commented Oct 18, 2021

Thank you for the report.
@aardvark179 Could you look into this?

@aardvark179
Copy link
Contributor

Thanks for this one. It's not just bignums that aren't being handled here, it appears rationals should also be converted.

@aardvark179
Copy link
Contributor

aardvark179 commented Dec 29, 2021

Fix in commit 39d740b.

@eregon eregon added this to the 22.1.0 milestone Jan 3, 2022
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