June 12, 2023 [Issue 23987] New: Copy construction should not disable implicit conversion | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23987 Issue ID: 23987 Summary: Copy construction should not disable implicit conversion Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: timon.gehr@gmx.ch DMD 2.104.0: ```d struct T { // no copy constructor } struct S { this(const ref S _){ // dummy copy constructor } } void main(){ void foo()inout{ immutable(T) t1; auto t2=t1; // ok, can convert from mutable to immutable immutable(S) s1; auto s2=s1; // error, copy constructor returns mutable, but immutable is required } } ``` The code should compile, it can just create a mutable object and convert it to immutable, as in the first case. -- |
Copyright © 1999-2021 by the D Language Foundation