Skip to content

Convertions can't compare BigInt to numerics #654

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

Closed
DarkDimius opened this issue Jun 15, 2015 · 2 comments
Closed

Convertions can't compare BigInt to numerics #654

DarkDimius opened this issue Jun 15, 2015 · 2 comments

Comments

@DarkDimius
Copy link
Contributor

[info] /Users/dark/workspace/dotty/tests/partest-generated/run/is-valid-num.scala:213: error: type mismatch:
[info]  found   : Byte(-128)
[info]  required: scala.math.BigInt
[info]     val isByte = bi >= Byte.MinValue && bi <= Byte.MaxValue
[info]                             ^
[info] /Users/dark/workspace/dotty/tests/partest-generated/run/is-valid-num.scala:213: error: type mismatch:
[info]  found   : Byte(127)
[info]  required: scala.math.BigInt
[info]     val isByte = bi >= Byte.MinValue && bi <= Byte.MaxValue
[info]                                                    ^
[info] /Users/dark/workspace/dotty/tests/partest-generated/run/is-valid-num.scala:214: error: type mismatch:
[info]  found   : Short(-32768)
[info]  required: scala.math.BigInt
[info]     val isShort = bi >= Short.MinValue && bi <= Short.MaxValue
[info]                               ^
[info] /Users/dark/workspace/dotty/tests/partest-generated/run/is-valid-num.scala:214: error: type mismatch:
[info]  found   : Short(32767)
[info]  required: scala.math.BigInt
[info]     val isShort = bi >= Short.MinValue && bi <= Short.MaxValue
[info]                                                       ^
[info] /Users/dark/workspace/dotty/tests/partest-generated/run/is-valid-num.scala:215: error: type mismatch:
[info]  found   : Char('\00')
[info]  required: scala.math.BigInt
[info]     val isChar = bi >= Char.MinValue && bi <= Char.MaxValue
[info]                             ^
[info] /Users/dark/workspace/dotty/tests/partest-generated/run/is-valid-num.scala:215: error: type mismatch:
[info]  found   : Char('�')
[info]  required: scala.math.BigInt
[info]     val isChar = bi >= Char.MinValue && bi <= Char.MaxValue
@odersky
Copy link
Contributor

odersky commented Jun 19, 2015

This is a consequence of the fact that we dropped weak conformance in Dotty. BigInt has an implicit conversion from Int to BigInt, but none from Byte, Short, Char. And we cannot chain implicit conversions.

The proper solution should be to give BigInt the missing conversions.
We can add them to DottyPredef for the moment.

@smarter
Copy link
Member

smarter commented Nov 18, 2015

Fixed by #902, leaving open until we move this test out of pending.

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

4 participants