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

BigDecimal wouldn't throw RuntimeError when round mode is set #1631

Closed
deepj opened this issue Mar 21, 2019 · 5 comments
Closed

BigDecimal wouldn't throw RuntimeError when round mode is set #1631

deepj opened this issue Mar 21, 2019 · 5 comments
Assignees
Labels
Milestone

Comments

@deepj
Copy link

deepj commented Mar 21, 2019

TruffleRuby doesn't support the round mode yet (See #1509). But there is another problem with that.

It's used in Hanami::Utils in https://github.com/hanami/utils/blob/master/lib/hanami/utils/kernel.rb#L420

Due this, several Hanami::Utils specs fail

To reproduce:

require 'bigdecimal'

BigDecimal(Time.new, ::Float::DIG)

Error:

Traceback (most recent call last):
        5: from ~/.rubies/truffleruby-1.0.0-rc14/bin/irb:31:in `<main>'
        4: from (irb):2
        3: from ~/.rubies/truffleruby-1.0.0-rc14/lib/truffle/bigdecimal.rb:293:in `BigDecimal'
        2: from ~/.rubies/truffleruby-1.0.0-rc14/lib/truffle/bigdecimal.rb:293:in `new'
        1: from ~/.rubies/truffleruby-1.0.0-rc14/lib/truffle/bigdecimal.rb:293:in `initialize'
RuntimeError (com.oracle.truffle.object.basic.DynamicObjectBasic cannot be cast to java.math.BigDecimal (ClassCastException))
	from org.truffleruby.stdlib.bigdecimal.CreateBigDecimalNode.create(CreateBigDecimalNode.java:209)
	from org.truffleruby.stdlib.bigdecimal.CreateBigDecimalNodeFactory$CreateBigDecimalNodeGen.executeAndSpecialize(CreateBigDecimalNodeFactory.java:506)
	from org.truffleruby.stdlib.bigdecimal.CreateBigDecimalNodeFactory$CreateBigDecimalNodeGen.executeInitialize(CreateBigDecimalNodeFactory.java:198)
	from org.truffleruby.stdlib.bigdecimal.BigDecimalCoreMethodNode.initializeBigDecimal(BigDecimalCoreMethodNode.java:57)
	from org.truffleruby.stdlib.bigdecimal.BigDecimalNodes$InitializeNode.initialize(BigDecimalNodes.java:63)
	from org.truffleruby.stdlib.bigdecimal.BigDecimalNodesFactory$InitializeNodeFactory$InitializeNodeGen.executeAndSpecialize(BigDecimalNodesFactory.java:158)
	from org.truffleruby.stdlib.bigdecimal.BigDecimalNodesFactory$InitializeNodeFactory$InitializeNodeGen.execute(BigDecimalNodesFactory.java:140)
	from org.truffleruby.language.control.SequenceNode.execute(SequenceNode.java:34)
	from org.truffleruby.language.methods.ExceptionTranslatingNode.execute(ExceptionTranslatingNode.java:51)
	from org.truffleruby.language.RubyRootNode.execute(RubyRootNode.java:54)
Translated to internal error

MRI 2.5.5

TypeError: no implicit conversion of Time into String
	from (irb):3:in `BigDecimal'
	from (irb):3
	from /usr/bin/irb:11:in `<main>'

I guess, TruffleRuby would follow the error message of MRI as well and not the above one which is confusing.

@deepj deepj changed the title BigDecimal would throw RuntimeError instead of TypeError when precision argument is set BigDecimal would throw RuntimeError instead of TypeError when round mode is set Mar 21, 2019
@deepj deepj changed the title BigDecimal would throw RuntimeError instead of TypeError when round mode is set BigDecimal wouldn't throw RuntimeError instead of TypeError when round mode is set Mar 21, 2019
@deepj deepj changed the title BigDecimal wouldn't throw RuntimeError instead of TypeError when round mode is set BigDecimal wouldn't throw RuntimeError when round mode is set Mar 21, 2019
@nirvdrum nirvdrum self-assigned this Mar 22, 2019
@nirvdrum
Copy link
Collaborator

Thanks for the report. As you've no doubt noticed, we don't pass a fair number of the BigDecimal specs. I'll add the functionality required here, but we really need to take a more in-depth pass on this library.

@deepj
Copy link
Author

deepj commented Apr 15, 2019

@nirvdrum this is fixed in #1509 (comment) by @chrisseaton

@deepj
Copy link
Author

deepj commented Apr 18, 2019

@chrisseaton this can be closed. It's fixed in the master. And there is only one failure in Hanami::Utils specs. And this issue #1649

@deepj
Copy link
Author

deepj commented May 8, 2019

@nirvdrum ^^^

@nirvdrum nirvdrum added this to the 1.0.0-rc16 milestone May 28, 2019
@nirvdrum nirvdrum added the bug label May 28, 2019
@nirvdrum
Copy link
Collaborator

Thanks for verifying that this has been fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants