www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - assertion failure with template instantiation of forward reference

reply "comco" <void.unsigned gmail.com> writes:
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?
Nov 28 2012
next sibling parent "bearophile" <bearophileHUGS lycos.com> writes:
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
Nov 28 2012
prev sibling parent "comco" <void.unsigned gmail.com> writes:
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!
Nov 29 2012