digitalmars.D.bugs - [Issue 19885] New: possibility to skip required initialization in
- d-bugmail puremagic.com (38/38) May 18 2019 https://issues.dlang.org/show_bug.cgi?id=19885
https://issues.dlang.org/show_bug.cgi?id=19885 Issue ID: 19885 Summary: possibility to skip required initialization in constructor using ref parameter Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Severity: regression Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: regnellday protonmail.com This code compiles (since 2.081.2), but shouldn't: struct A { disable this(); this(int) {} } struct B { A a; this(int) { f(a); } } void f(ref A a) {} void main() { B b = B(1); } The `a` must be constructed in the `B` constructor. But if we pass it somewhere via ref parameter, compiler ignores `a` and leaves it in default state. By the way, if we change ref to out, then there is normal `Error: cannot have out parameter of type A because the default construction is disabled`. --
May 18 2019