title: Using the `in` keyword causes "E1012 Constant expression violates subrange bounds" in Delphi
body: <p>I've come across some rather unusual behaviour in a bit of Delphi code. When using the <code>in</code> keyword to check if an item is in a constant array, I get the following compilation error:</p>
  
  <blockquote>
    <p>E1012 Constant expression violates subrange bounds</p>
  </blockquote>
  
  <p>The constants are defined as follows:</p>
  
  <pre><code>type TSomeEnum = (seFoo = 1000,
                    seBar = 2000,
                    seBoo = 3000,
                    seFar = 4000,
                    seFooBar = 5000,
                    seBooFar = 6000,
                    seLow = 1000,
                    seHigh = 6000,
                    seCount = 6);
  </code></pre>
  
  <p>The line that is failing is the following:</p>
  
  <pre><code>if someObj.someProperty in [seFoo, seFar, seFooBar] then
  ...
  </code></pre>
  
  <p>Whilst I understand the reasoning behind the error showing in <a href="https://stackoverflow.com/questions/10599685/e1012-constant-expression-violates-subrange-bounds-why-does-it-work-with-varia">another question posted here</a>, where bounds checking on integer arrays wasn't done at compile time when using a variable, it seems odd that I'm getting the same problem with a constant array which is most certainly within bounds.</p>
  
  <p>For now, I've replaced the line with a (much larger) statement comprising of <code>or</code> clauses. However, this is clearly not ideal. Can anyone shed any light on why I'm getting this problem?</p>