Thread overview
[Issue 21369] Compiler doesn't allow lvalues via alias this when wrapper is an rvalue
May 08, 2021
Basile-z
May 08, 2021
apham
Dec 17, 2022
Iain Buclaw
November 08, 2020
https://issues.dlang.org/show_bug.cgi?id=21369

Steven Schveighoffer <schveiguy@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Hardware|x86                         |All
                 OS|Mac OS X                    |All

--
May 08, 2021
https://issues.dlang.org/show_bug.cgi?id=21369

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |b2.temp@gmx.com

--- Comment #1 from Basile-z <b2.temp@gmx.com> ---
The problem is likely the use of `Type.aliasthisOf()` which returns a `Type`, so for a function this is TypeFunction.nextOf() and as `ref` is not a type qual, the information is lost and DMD thinks it's a rvalue.

--
May 08, 2021
https://issues.dlang.org/show_bug.cgi?id=21369

apham <apz28@hotmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |apz28@hotmail.com

--- Comment #2 from apham <apz28@hotmail.com> ---
Create temp var is OK

struct S
{
   int *val;
   ref int get() { return *val; }
   alias get this;
}

void foo(ref int x) {}

void main()
{
   int x;
   auto s = S(&x);
   foo(s);
}

--
May 11, 2021
https://issues.dlang.org/show_bug.cgi?id=21369

--- Comment #3 from Steven Schveighoffer <schveiguy@gmail.com> ---
(In reply to apham from comment #2)
> Create temp var is OK

That doesn't trigger the bug because then s is an lvalue.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=21369

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--