Shin Fujishiro <> changed:

           What    |Removed                     |Added
                 CC|                            |

--- Comment #2 from Shin Fujishiro <> 2010-11-02 22:09:58 PDT 
The bug happens if a recursive template is instantiated via an alias:

  alias Bug3276 W;
  alias W!true w;

In template.c, the following if at the line 4304 tries to get the relevant
TemplateDeclaration for doing recursion:

TemplateDeclaration *TemplateInstance::findTemplateDeclaration(Scope *sc)
        TemplateInstance *ti;
        if (s->parent &&
            (ti = s->parent->isTemplateInstance()) != NULL)
            if (
                (ti->name == id ||
                 ti->toAlias()->ident == id)    // <-- the cause

Here 'this' refers to the recursive instantiation "Bug3276!(false)" and
id="Bug3276" is its identifier.  'ti' is the enclosing TemplateInstance (i.e.

The test sees if the identifier 'id' used in the instantiation
"Bug3276!(false)" is the same as the one of enclosing 'ti'.  But 'ti' was
instantiated with the aliased identifier (ti->name="W"), so the first condition
isn't met.

Then it tests the next condition: ti->toAlias()->ident.  It dives into the
following code in TemplateInstance::toAlias():

    if (aliasdecl)
        return aliasdecl->toAlias();

Here 'aliasdecl' is the "result" of the eponymous template "Bug3276!(true)",
and it's exactly the "alias Bug3276!(false)" analyzing now. 
AliasDeclaration::toAlias() does the follownig check:

    if (inSemantic)
    {   error("recursive alias declaration");
        aliassym = new TypedefDeclaration(loc, ident, Type::terror, NULL);

Since it's in semantic, the compiler raises the error.

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to