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.
Comment #1 by dlang-bot — 2023-05-09T13:12:18Z
@RazvanN7 created dlang/dmd pull request #15214 "Fix Issue 18151 - wrong auto ref lvalue inference for implicitly converted alias this parameters" fixing this issue:
- Fix Issue 18151 - wrong auto ref lvalue inference for implicitly converted alias this parameters
https://github.com/dlang/dmd/pull/15214
Comment #2 by robert.schadek — 2024-12-13T18:55:57Z