title: Hex-literals, compiler error or badly written spec?
body: <p>Scala spec says</p>
  
  <blockquote>
    <h3>1.3.1 Integer Literals</h3>
    
    <p>Syntax:</p>
  
  <pre><code>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’
  </code></pre>
    
    <p>Integer literals are usually of type Int, or of type Long when followed by a <code>L</code> or <code>l</code>
    suffix. Values of type Int are all integer numbers between -2<sup>31</sup> and 2<sup>31</sup>-1, inclusive. Values of type Long are all integer numbers between -2<sup>63</sup> and 2<sup>63</sup>-1, inclusive.
    A compile-time error occurs if an integer literal denotes a number outside these
    ranges</p>
  </blockquote>
  
  <p>Last time I checked <code>0x80000000</code> equals 2147483648 which should be out of range for an <code>Int</code> (<em>"between -2<sup>31</sup> and 2<sup>31</sup>-1, inclusive"</em>).</p>
  
  <p>Still the compiler does <em>not</em> complain but instead lets the integer overflow into -2147483648.</p>
  
  <p>So, is the spec wrong, is the compiler wrong, or have I misunderstood anything?</p>
  
  <p><strong>Edit:</strong> The same number, written in decimal form is treated correctly and produces an error.</p>