Skip to content

Commit

Permalink
Add assertion and fix AST identity that had broken by template instan…
Browse files Browse the repository at this point in the history
…tiation
  • Loading branch information
9rnsr committed Mar 18, 2013
1 parent f138c29 commit 20fe5e8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/struct.c
Expand Up @@ -655,6 +655,15 @@ void StructDeclaration::semantic(Scope *sc)
deferred->semantic2(sc);
deferred->semantic3(sc);
}

#if 0
if (type->ty == Tstruct && ((TypeStruct *)type)->sym != this)
{
printf("this = %p %s\n", this, this->toChars());
printf("type = %d %s, sym = %p\n", type->ty, type->toChars(), ((TypeStruct *)type)->sym);
}
#endif
assert(type->ty != Tstruct || ((TypeStruct *)type)->sym == this);
}

Dsymbol *StructDeclaration::search(Loc loc, Identifier *ident, int flags)
Expand Down
11 changes: 9 additions & 2 deletions src/template.c
Expand Up @@ -5050,7 +5050,11 @@ void TemplateInstance::semantic(Scope *sc, Expressions *fargs)
#endif

// Copy the syntax trees from the TemplateDeclaration
members = Dsymbol::arraySyntaxCopy(tempdecl->members);
if (members && speculative)
{} // Don't copy again so they were previously created.
else
members = Dsymbol::arraySyntaxCopy(tempdecl->members);

// todo for TemplateThisParameter
for (size_t i = 0; i < tempdecl->parameters->dim; i++)
{
Expand Down Expand Up @@ -6511,7 +6515,10 @@ void TemplateMixin::semantic(Scope *sc)
}

// Copy the syntax trees from the TemplateDeclaration
members = Dsymbol::arraySyntaxCopy(tempdecl->members);
if (scx && members)
{} // Don't copy again so they were previously created.
else
members = Dsymbol::arraySyntaxCopy(tempdecl->members);
if (!members)
return;

Expand Down

0 comments on commit 20fe5e8

Please sign in to comment.