Why simple code using Rebindable doesn't compile ?

chmike via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon May 30 01:15:01 PDT 2016


Hello,

here is a program stripped down to the minimum code that doesn't 
compile

----
import std.typecons;

Rebindable!(immutable TestImpl) Test;

Rebindable!(immutable TestImpl) Test;

class TestImpl
{
     void foo() {}
     Test test() { __gshared x = new immutable TestImpl; return 
rebindable(x); }
}

void main()
{
     Test t = Test.test;
}

void main()
{
     Test t = Test.test;
}
----

source/app.d(32,10): Error: circular reference to 'app.Test'
source/app.d(32,10): Error: Test is used as a type
/usr/include/dmd/phobos/std/typecons.d(1616,20): Error: template 
instance std.traits.isDynamicArray!(immutable(TestImpl)) error 
instantiating
source/app.d(27,1):        instantiated from here: 
Rebindable!(immutable(TestImpl))
/usr/include/dmd/phobos/std/typecons.d(1625,17): Error: mixin 
std.typecons.RebindableCommon!(immutable(TestImpl), TestImpl, 
Rebindable) does not match template declaration 
RebindableCommon(T, U, alias This) if (is(T == class) || is(T == 
interface) || isAssociativeArray!T)




More information about the Digitalmars-d-learn mailing list