Scala spec says
1.3.1 Integer Letters
Syntax:
integerLiteral ::= (decimalNumeral | hexNumeral | octalNumeral) ['L' | 'l'] decimalNumeral ::= '0' | nonZeroDigit {digit} hexNumeral ::= '0' 'x' hexDigit {hexDigit} octalNumeral ::= '0' octalDigit {octalDigit} digit ::= '0' | nonZeroDigit nonZeroDigit ::= '1' | · · · | '9' octalDigit ::= '0' | · · · | '7'
Integer literals are usually of type Int or type Long, followed by L or L suffix. Values of type Int are integers between -2 31 and 2 31 -1 inclusive. Values of type Long are integers between -2 63 and 2 63 -1 inclusive. A compile-time error occurs if an integer literal denotes a number outside these ranges
Last time, I checked 0x80000000 equal to 2147483648, which should be out of range for Int ("between -2 31 and 2 31 -1 inclusive").
However, the compiler does not complain, but instead translates the integer to -2147483648.
So, the wrong specification, the wrong compiler, or didn’t I understand something?
Edit: The same number written in decimal is processed correctly and generates an error.
source share