[Issue 18151] New: wrong auto ref lvalue inference for implicitly converted alias this parameters

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Jan 2 20:02:59 UTC 2018


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 at puremagic.com
          Reporter: code at 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.

--


More information about the Digitalmars-d-bugs mailing list