[Issue 15784] New: Overload set constructor call should be supported from inside a constructor
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Thu Mar 10 06:50:45 PST 2016
https://issues.dlang.org/show_bug.cgi?id=15784
Issue ID: 15784
Summary: Overload set constructor call should be supported from
inside a constructor
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Keywords: rejects-valid
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: k.hara.pg at gmail.com
>From issue 15744 test case:
template AddField(T) {
T b;
this(Args...)(T b, auto ref Args args)
{
this.b = b;
//this(args); // not OK (segfaults, issue 15744)
}
}
template construcotrs() {
int a;
this(int a) {
this.a = a;
}
}
struct Bar {
mixin construcotrs;
mixin AddField!(string);
}
void main() {
auto bar1 = Bar(5); // OK
auto bar2 = Bar("bar", 15); // also OK
}
In main, outside of construction functions, the Bar's overload set constructor
(declared in AddField and constructors mixin template) called is accepted.
But from inside the constructor AddField.this(Args...)(T b, auto ref Args
args), a constructor call this(args); cannot work.
it's merely inconsistent behavior, and should be treated as a rejects-valid
bug.
--
More information about the Digitalmars-d-bugs
mailing list