https://issues.dlang.org/show_bug.cgi?id=22509

          Issue ID: 22509
           Summary: Invalid implicit conversion from int* to
                    immutable(int*)
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nob...@puremagic.com
          Reporter: thomas.bock...@gmail.com

`immutable immutA = a.ptr;` should be a compile-time error, just like
`immutable immutB = b.ptr;` is:

//////////////////////////////////////////////////////////
module app;

struct A(P) {
    P ptr() inout @safe {
        return null; }
}

struct B {
    int* ptr() inout @safe {
        return null; }
}

void main() @safe {
    immutable A!(int*) a;
    immutable immutA = a.ptr; // Accepts invalid!

    immutable B b;
    immutable immutB = b.ptr; // Error: cannot implicitly convert expression
`b.ptr()` of type `int*` to `immutable(int*)`

}
//////////////////////////////////////////////////////////

--

Reply via email to