[Issue 13827] New: Internal Compiler Error: null field

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Dec 7 04:49:59 PST 2014


https://issues.dlang.org/show_bug.cgi?id=13827

          Issue ID: 13827
           Summary: Internal Compiler Error: null field
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: DMD
          Assignee: nobody at puremagic.com
          Reporter: temtaime at gmail.com

mixin template VectorImpl() {
    this(A...)(auto ref in A args) {
        uint k;

        foreach(ref v; args)
            flat[k++] = cast(T)v;
    }
}

struct Matrix(T, uint _M, uint _N = _M) {

    enum {
        M = _M, //rows
        N = _N, //columns
        C = M * N, // count of elements

        isVector = N == 1 || M == 1,
    }

    private static defaultMatrix() {
        T arr[M][N] = void;

            foreach(i, ref v; arr) {
                v[] = 0;
                static if(M == N) v[i] = 1;
            }

        return arr;
    }

    union {
        T[N][M] A = defaultMatrix;
        T[C] flat;
    }

    mixin VectorImpl;
}

alias Vector(T, uint M) = Matrix!(T, 1, M);

alias Vector3 = Vector!(float, 3);

enum isMatrix(T) = is(T == Matrix!A, A...);

template isVector(T) {
    static if(isMatrix!T) enum isVector = T.isVector;
    else enum isVector = false;
}

enum S = Vector3(1, 2, 3);

void main() {
}

main.d(6): Error: Internal Compiler Error: null field flat
main.d(6): Error: cannot determine length of this.flat at compile time
main.d(50):        called from here: Matrix([[0.000000F, 0.000000F,
0.000000F]], ).this(1, 2, 3)


Maybe one can reduce it more. This code compiles on 2.066.

--


More information about the Digitalmars-d-bugs mailing list