The regression appears between 2.072.1 and 2.072.2
test case:
mixin template impl()
{
import std.traits : BaseClassesTuple;
alias T = typeof(this);
enum doImplement = is(T : I) && !(is(BaseClassesTuple!T[0] : I));
static if (doImplement)
void method(){}
}
interface I {void method();}
class A : I {mixin impl;}
void main(){}
fails to compile and outputs
/tmp/temp_7F9D9403AD90.d(8,16): Error: circular reference to variable 'runnable.A.impl!().doImplement'
cat > bug.d << CODE
mixin template impl()
{
alias T = typeof(this);
enum doImplement = is(T : I) ;
static if (doImplement)
{}
}
interface I {}
class A : I {mixin impl;}
CODE
dmd -c -o- bug
----
bug.d(6): Error: circular reference to variable 'bug.A.impl!().doImplement'
bug.d(11): Error: mixin bug.A.impl!() error instantiating
----
> If i trust a bisect made by hand, the fix for issue 16980 is the culprit, so this pull: https://github.com/dlang/dmd/pull/6383
Digger confirms that it was introduced with https://github.com/dlang/dmd/pull/6383.
Comment #3 by github-bugzilla — 2017-01-10T06:32:14Z
Commits pushed to stable at https://github.com/dlang/dmdhttps://github.com/dlang/dmd/commit/c4ac1abed6e6aa95b1312d777f77fb634e2dac07
fix Issue 17059 - incorrect circular reference with `is(Klass : Interface)`
- fixed by tweaking the fix for Issue 16980 (#6383)
- happened b/c TypeClass::implicitConv -> TypeClass::constConv checks
for offset == 0, which triggered size finalization
- instead handle unfinalized classes in isBaseOf (new OFFSET_FWDREF)
and only explicity finalize size before optimizing casts
- add a halt for any OFFSET_FWDREF leaking through to IR gen
https://github.com/dlang/dmd/commit/45c886fab62ed8a99ab054d3d5e9c2e6a38e429e
Merge pull request #6412 from MartinNowak/fix17059
fix Issue 17059 - incorrect circular reference with `is(Klass : Interface)`
Comment #4 by github-bugzilla — 2017-01-15T01:21:02Z