www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 19251] New: Alias this does not get called on struct

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

          Issue ID: 19251
           Summary: Alias this does not get called on struct qualified
                    type
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: razvan.nitu1305 gmail.com

struct A
{
    int[] a;
    immutable(A) fun()
    {
        writeln("Yo");
        return immutable A([7]);
    }

    alias fun this;
}

void main()
{
    A a;
    immutable A b = a;   // error: cannot implicitly convert expression a of
type A to immutable(A)
}

This code should print YO.

--
Sep 18 2018