May 25
https://issues.dlang.org/show_bug.cgi?id=24566

          Issue ID: 24566
           Summary: condition that starts with runtime value and uses
                    compile time array does not short circuit
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody@puremagic.com
          Reporter: schveiguy@gmail.com

If I mix a runtime and compile time expression in a condition, short circuiting doesn't prevent a compile-time bounds check for constant folded arrays.

```d
enum a = true;
bool b = true;
enum str = "a";
if(a && str.length > 1 && str[1] == 'a') {} // ok
if(b && str.length > 1 && str[1] == 'a') {} // compiler error
if(!b && str.length > 1 && str[1] == 'a') {} // compiler error
if(str.length > 1 && b && str[1] == 'a') {} // ok
```

The error is:
Error: string index 1 is out of bounds [0 .. 1]

If the runtime condition is not first, then it compiles.

Note that even if the runtime condition is false and should short circuit the whole thing, the compiler still errors.

As far as I can tell, this has always been the case, so not a regression. Though a related issue might be issue 22646.

--