www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 14678] New: Bogus cannot create a struct until its size is

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

          Issue ID: 14678
           Summary: Bogus cannot create a struct until its size is
                    determined error
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: deadalnix gmail.com

See sample code:

enum AstTypeKind {
    Foo,
    Bar,
}

struct AstType {
    mixin TypeMixin!(AstTypeKind, Payload);

    this(AstTypeKind) {
    }

    import othermodule;
}

alias ParamAstType = AstType.ParamType;

union Payload {
    ParamAstType* params;
}

template TypeMixin(K, Payload) {

    Payload payload;

    alias ParamType = PackedType!(typeof(this));

    struct PackedType(T, U...) {

        Payload payload;

        auto getType() {
            return T(AstTypeKind.Foo);
        }
    }
}

Other module can be an empty file. What is in it doesn't matter, the import
being there is the only thing that does matter.

Line 32: Error: cannot create a struct until its size is determined
Line 25: Error: template instance type.AstType.TypeMixin!(AstTypeKind,
Payload).PackedType!(AstType) error instantiating

--
Jun 10 2015