Thread overview
assertion failure with template instantiation of forward reference class
Nov 29, 2012
comco
Nov 29, 2012
bearophile
Nov 29, 2012
comco
November 29, 2012
When trying to compile this code:

import std.stdio;
class A;

class B(T) : T {
}

void main() {
    writeln(typeid(B!A));
}

I get this error: Assertion failure: '!scope' on line 358 in file 'toobj.c'.
Shouldn't it be more like: Error: class main.A unable to resolve forward reference in definition

Looks like a bug?
November 29, 2012
comco:

> Looks like a bug?

This is what DMD 2.061alpha prints, it doesn't crash:

...\dmd2\src\phobos\std\range.d(603): Error: static assert  "Cannot put a string into a LockingTextWriter"
...\dmd2\src\phobos\std\format.d(2349):        instantiated from here: put!(LockingTextWriter, string)
...\dmd2\src\phobos\std\format.d(2782):        instantiated from here: formatValue!(LockingTextWriter, TypeInfo_Class, char)
...\dmd2\src\phobos\std\format.d(415):        instantiated from here: formatGeneric!(LockingTextWriter, TypeInfo_Class, char)
...\dmd2\src\phobos\std\stdio.d(712):        ... (1 instantiations, -v to show) ...
...\dmd2\src\phobos\std\stdio.d(1618):        instantiated from here: write!(TypeInfo_Class,char)
test.d(5):        instantiated from here: writeln!(TypeInfo_Class)

Bye,
bearophile
November 29, 2012
On Thursday, 29 November 2012 at 01:38:50 UTC, bearophile wrote:
> comco:
>
>> Looks like a bug?
>
> This is what DMD 2.061alpha prints, it doesn't crash:
>
> ...\dmd2\src\phobos\std\range.d(603): Error: static assert  "Cannot put a string into a LockingTextWriter"
> ...\dmd2\src\phobos\std\format.d(2349):        instantiated from here: put!(LockingTextWriter, string)
> ...\dmd2\src\phobos\std\format.d(2782):        instantiated from here: formatValue!(LockingTextWriter, TypeInfo_Class, char)
> ...\dmd2\src\phobos\std\format.d(415):        instantiated from here: formatGeneric!(LockingTextWriter, TypeInfo_Class, char)
> ...\dmd2\src\phobos\std\stdio.d(712):        ... (1 instantiations, -v to show) ...
> ...\dmd2\src\phobos\std\stdio.d(1618):        instantiated from here: write!(TypeInfo_Class,char)
> test.d(5):        instantiated from here: writeln!(TypeInfo_Class)
>
> Bye,
> bearophile

Nice. Thanks!