[Issue 23987] New: Copy construction should not disable implicit conversion
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Mon Jun 12 13:56:18 UTC 2023
    
    
  
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 at puremagic.com
          Reporter: timon.gehr at 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.
--
    
    
More information about the Digitalmars-d-bugs
mailing list