Rebindable and alias this to inout property

FreeSlave freeslave93 at gmail.com
Fri Jul 24 14:24:29 UTC 2020


Consider the following code

import std.typecons;

class Internal
{
}

class Class
{
     inout(Internal) internal() inout {
         return _internal;
     }
     alias internal this;
     Internal _internal;
}

void main(string[] args)
{
     const c = new Class;
     auto r = c.rebindable;
}

When compiling with dmd it reports the error:

/usr/include/dmd/phobos/std/typecons.d(2173): Error: pure 
function 
std.typecons.Rebindable!(const(Class)).Rebindable.RebindableCommon!(const(Class), Class, Rebindable!(const(Class))).opAssign cannot call impure delegate std.typecons.Rebindable!(const(Class)).Rebindable.RebindableCommon!(const(Class), Class, Rebindable!(const(Class))).opAssign.__lambda2
/usr/include/dmd/phobos/std/typecons.d(2173): Error: @nogc 
function 
std.typecons.Rebindable!(const(Class)).Rebindable.RebindableCommon!(const(Class), Class, Rebindable!(const(Class))).opAssign cannot call non- at nogc delegate std.typecons.Rebindable!(const(Class)).Rebindable.RebindableCommon!(const(Class), Class, Rebindable!(const(Class))).opAssign.__lambda2
main.d(20): Error: template instance 
std.typecons.rebindable!(const(Class)) error instantiating

Note that this code was compilable on dmd 2.083.
Should we call it a regression?


More information about the Digitalmars-d mailing list