www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24386] New: [REG 2.095.1] constructor has no function body

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

          Issue ID: 24386
           Summary: [REG 2.095.1] constructor has no function body with
                    return type inference
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: tim.dlang t-online.de

The following code does not compile since DMD 2.095.1:
```
template FunctionParameters(alias F)
{
    static if (is(typeof(F) P == __parameters))
        alias FunctionParameters = P;
}

template numConstructorOverloads(Overloads...)
{
    static if (Overloads.length == 0)
        enum numConstructorOverloads = false;
    else
        enum numConstructorOverloads = __traits(getOverloads,
FunctionParameters!(Overloads[0]), "__ctor").length
            + numConstructorOverloads!(Overloads[1 .. $]);
}

enum MIXIN = q{
    this(Params...)(auto ref Params params)
        if (numConstructorOverloads!(__traits(getOverloads, typeof(this),
"__ctor")))
    {
    }
};

struct Wrapper(T)
{
    T data;
}

struct Struct1
{
    Wrapper!(Struct2)* splitRef;
    this(long);
    this(int);
    mixin(MIXIN);
}

struct Struct2
{
    this(const(Struct1)* )
    {
    }
    this(ref const(Struct2) )
    {
    }
    mixin(MIXIN);
}
```

The code compiled with DMD 2.095.0, but results in the following error message
since DMD 2.095.1:
Error: constructor `test.Struct1.this` has no function body with return type
inference

--
Feb 11