So why is this happening?! It connects to that old can't reproduce the negative zero bug (I can't remember which ticket that was).
heliumFri 31 Dec 2010
It has nothing to do with the negative zero bug.
9223372036854775808 is simply not a valid numerical literal in Fantom.
a := -9223372036854775808
produces the same error.
go4Fri 31 Dec 2010
Yes, int64 included in the closed range [-9223372036854775808~9223372036854775807]. So -9223372036854775808 and 9223372036854775807 should be valid integer.
And -9223372036854775808 bit is 10000000000000000000000000000000000000000000000... same as -0f (the complement of float 0)
DanielFathFri 31 Dec 2010
@helium: I know it isn't a valid literal, but as go4 said, it is the same as Int.minVal. So why isn't Int.minVal a valid Int literal (while Int.maxVal is)?
brianSat 1 Jan 2011
The problem is that -xxxx isn't a literal itself, but is parsed as -(xxxx), and the negative is handled later during constant folding. And in this case the actual positive value isn't a valid integer literal because it is one too big. So this happens to be one case where that prevents you from using a Fantom literal within the valid 64-bit range. Sort of annoying, but seems like such a small issue, that I didn't want to complicate the compiler with a special case.
DanielFathSat 1 Jan 2011
I see. Is this problem Java-specific or will it crop up on other platforms as well?
DanielFath Fri 31 Dec 2010
So why is this happening?! It connects to that old can't reproduce the negative zero bug (I can't remember which ticket that was).
helium Fri 31 Dec 2010
It has nothing to do with the negative zero bug.
9223372036854775808 is simply not a valid numerical literal in Fantom.
produces the same error.
go4 Fri 31 Dec 2010
Yes, int64 included in the closed range
[-9223372036854775808~9223372036854775807]
. So -9223372036854775808 and 9223372036854775807 should be valid integer.And -9223372036854775808 bit is
10000000000000000000000000000000000000000000000...
same as -0f (the complement of float 0)DanielFath Fri 31 Dec 2010
@helium: I know it isn't a valid literal, but as go4 said, it is the same as
Int.minVal
. So why isn'tInt.minVal
a validInt
literal (whileInt.maxVal
is)?brian Sat 1 Jan 2011
The problem is that -xxxx isn't a literal itself, but is parsed as -(xxxx), and the negative is handled later during constant folding. And in this case the actual positive value isn't a valid integer literal because it is one too big. So this happens to be one case where that prevents you from using a Fantom literal within the valid 64-bit range. Sort of annoying, but seems like such a small issue, that I didn't want to complicate the compiler with a special case.
DanielFath Sat 1 Jan 2011
I see. Is this problem Java-specific or will it crop up on other platforms as well?