-
Notifications
You must be signed in to change notification settings - Fork 19
No implicit widening conversions ... #30
No implicit widening conversions ... #30
Conversation
... floating-point types.
... subtyping relationship between integral and floating-point types.
... floating-point conversions
I think we'd want to put this behind a -Z flag or a language import to allow for source compatibility. Do you think that would be possible to achieve? As you expect, I am a big fan of this change, so assuming the compatibility concerns are addressed I would definitely vote for its inclusion. |
Probably, but adding configurability will probably 10 times more complicated than the fix itself. |
Note that there is still an issue remaining in one of the tests. (But I guess it won't matter currently, because we don't have a build bot yet.) |
@@ -57,7 +57,7 @@ trait Constants extends api.Constants { | |||
def isCharRange: Boolean = isIntRange && Char.MinValue <= intValue && intValue <= Char.MaxValue | |||
def isIntRange: Boolean = ByteTag <= tag && tag <= IntTag | |||
def isLongRange: Boolean = ByteTag <= tag && tag <= LongTag | |||
def isFloatRange: Boolean = ByteTag <= tag && tag <= FloatTag | |||
def isDoubleRange: Boolean= FloatTag == tag || tag == DoubleTag | |||
def isNumeric: Boolean = ByteTag <= tag && tag <= DoubleTag |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain what's going on here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is saying that only floats and doubles fit in doubles, instead of all the numeric types. Then it renames the method. Before there wasn't an "isDoubleRange" because in the context this was being used, that was always true. And afterward I suppose there's no "isFloatRange" because it would only be true for floats and thus never checked.
I agree with @non on this. We want it to be possible for existing code to be compiled with tlc with at most the addition of a compiler switch ... so working out how to do that cleanly isn't an optional extra, it's the most important thing. |
@@ -467,9 +467,5 @@ object Long extends AnyValCompanion { | |||
|
|||
/** The String representation of the scala.Long companion object. */ | |||
override def toString = "object scala.Long" | |||
/** Language mandated coercions from Long to "wider" types. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice comment paulp.
If you proceed with this or something like it you might want to give https://issues.scala-lang.org/browse/SI-8338 a look. |
See #34. |
@milessabin Yes, I'm aware of the issue. I only complain about the pain of implementing a flag, not the need to add it. |
Can one of the admins verify this patch? |
... between integral and floating point types.