www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21104] New: certain array operations fail during CTFE when


          Issue ID: 21104
           Summary: certain array operations fail during CTFE when used to
                    initialize a static array
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: elpenguino+D gmail.com

enum b = f();

int[4] f() {
    int[4] x = [1,2,3,4] * [1,2,3,4];
    return x;

f() works fine at runtime, but fails during CTFE with `Error: variable x cannot
be read at compile time`.

Looking at the -vcg-ast output, it becomes clear why: `int[4] x = arrayOp(x[],
[1, 2, 3, 4], [1, 2, 3, 4]);`. The presence of x in that statement is illegal.

Aug 02 2020