Thread overview
[Issue 21545] [dip1000] cannot assign ref returning delegate to variable with lower attributes
Jan 13, 2021
Bolpat
Jan 13, 2021
ag0aep6g
Jan 13, 2021
ag0aep6g
Dec 17, 2022
Iain Buclaw
January 13, 2021
https://issues.dlang.org/show_bug.cgi?id=21545

Bolpat <qs.il.paperinik@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
                 CC|                            |qs.il.paperinik@gmail.com

--
January 13, 2021
https://issues.dlang.org/show_bug.cgi?id=21545

ag0aep6g <ag0aep6g@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ag0aep6g@gmail.com

--- Comment #1 from ag0aep6g <ag0aep6g@gmail.com> ---
Bizarre:

void main()
{
    int i;
    auto dg = delegate ref() @safe => i;

    alias DgFull = ref int delegate() pure nothrow @nogc @safe;
    alias DgAuto = typeof(dg);

    pragma(msg, DgFull); /* int delegate() pure nothrow @nogc ref @safe */
    pragma(msg, DgAuto); /* int delegate() pure nothrow @nogc ref @safe */
    pragma(msg, is(DgFull == DgAuto)); /* true; okay */

    alias DgSafe = ref int delegate() @safe;

    pragma(msg, is(DgFull : DgSafe)); /* true; okay */
    pragma(msg, is(DgAuto : DgSafe)); /* false; wat */
}

--
January 13, 2021
https://issues.dlang.org/show_bug.cgi?id=21545

--- Comment #2 from ag0aep6g <ag0aep6g@gmail.com> ---
(In reply to ag0aep6g from comment #1)
>     int i;
>     auto dg = delegate ref() @safe => i;
> 
>     alias DgFull = ref int delegate() pure nothrow @nogc @safe;
>     alias DgAuto = typeof(dg);
> 
>     pragma(msg, DgFull); /* int delegate() pure nothrow @nogc ref @safe */
>     pragma(msg, DgAuto); /* int delegate() pure nothrow @nogc ref @safe */
>     pragma(msg, is(DgFull == DgAuto)); /* true; okay */

`DgAuto` actually also has the attributes`scope` and `return`, but they have a special "inferred" marker. That means they're not printed.[1] Apparently, the marker also has an effect on `is(X == Y)`. Still bizarre.


[1] https://github.com/dlang/dmd/blob/f341be3de711f9dbb91011e3650f8afc3818ec25/src/dmd/mtype.d#L7131-L7134

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

Iain Buclaw <ibuclaw@gdcproject.org> changed:

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

--
December 13
https://issues.dlang.org/show_bug.cgi?id=21545

--- Comment #3 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/19853

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--