www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18151] New: wrong auto ref lvalue inference for implicitly

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

          Issue ID: 18151
           Summary: wrong auto ref lvalue inference for implicitly
                    converted alias this parameters
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P3
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: code dawg.eu

cat > bug.d << CODE
void test()(auto ref Inner inner)
{
    pragma(msg, __traits(isRef, inner) ? "ref" : "value");
}

struct Inner
{
}

struct Outer
{
    Inner inner;
    Inner get() { return inner; }
    alias get this;
}

void bug()
{
    Outer outer;
    test(outer);
}
CODE
dmd -c bug.d
----
ref
bug.d(20): Error: outer.get() is not an lvalue
----

Happens apparently because auto ref is resolved before implicit alias this
conversion kicks in.

--
Jan 02