Test case:
module test;
public class Derived : public Base
{
}
class Template(T)
{
}
alias Template!(bool) TemplateAlias;
class Base
{
TemplateAlias templateAlias;
}
# dmd test.d
test.d(13): Error: forward reference to 'Template!(bool)'
test.d(13): Error: TemplateAlias is used as a type
test.d(13): Error: variable test.Base.templateAlias voids have no value
Regression since DMD2.031, blocker for me to upgrate to a newer compiler version.
Comment #1 by clugdbug — 2010-01-24T23:58:37Z
This is also a D1 regression. It worked on 1.046, fails on 1.047 and later.
Comment #2 by clugdbug — 2010-01-25T02:07:38Z
The regression was caused by adding a couple of lines to ClassDeclaration::semantic(Scope *sc) in class.c in D1.047.
I think this was probably part of the fix for bug 3170.
Currently line 350 in the D1 source, commenting out the two lines marked '-' allows this test case to compile again. I think the bug lies elsewhere, however.
=========
if (!tc->sym->symtab || tc->sym->scope || tc->sym->sizeok == 0)
{
//printf("%s: forward reference of base class %s\n", toChars(), tc->sym->toChars());
//error("forward reference of base class %s", baseClass->toChars());
// Forward reference of base class, try again later
//printf("\ttry later, forward reference of base class %s\n", tc->sym->toChars());
scope = scx ? scx : new Scope(*sc);
scope->setNoFree();
- if (tc->sym->scope)
- tc->sym->scope->module->addDeferredSemantic(tc->sym);
scope->module->addDeferredSemantic(this);
return;
}