digitalmars.D.bugs - [Issue 20695] New: Copy constructor disable default struct constructor
- d-bugmail puremagic.com (37/37) Mar 23 2020 https://issues.dlang.org/show_bug.cgi?id=20695
https://issues.dlang.org/show_bug.cgi?id=20695 Issue ID: 20695 Summary: Copy constructor disable default struct constructor Product: D Version: D2 Hardware: x86 OS: Mac OS X Status: NEW Keywords: C++, rejects-valid Severity: enhancement Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: pro.mathias.lang gmail.com ``` struct Bar { this(const ref Bar o) {} string a; uint b; } void main () { // foo.d(11): Error: struct Bar has constructors, cannot use { initializers }, use Bar( initializers ) instead Bar b = { a: "Hello", b: 42 }; // foo.d(12): Error: copy constructor foo.Bar.this(ref const(Bar) o) is not callable using argument types (string\ , int) // foo.d(12): cannot pass rvalue argument "Hello" of type string to parameter ref const(Bar) o Bar c = Bar("Hello", 42); } ``` Expected result: This should compile. It should also work if the constructor is ` disable`d. --
Mar 23 2020