Bug 15310 – [dmd-internal] TemplateDeclaration should be converted to TemplateExp always

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2015-11-10T02:47:00Z
Last change time
2016-02-29T17:48:08Z
Keywords
pull
Assigned to
nobody
Creator
k.hara.pg
Blocks
15311, 14603, 14604

Comments

Comment #0 by k.hara.pg — 2015-11-10T02:47:11Z
In DsymbolExp.resolve, a TemplateDeclaration is converted to TemplateExp. extern (C++) final class DsymbolExp : Expression { ... static Expression resolve(Loc loc, Scope *sc, Dsymbol s, bool hasOverloads) { ... if (TemplateDeclaration td = s.isTemplateDeclaration()) { auto p = td.toParent2(); auto fdthis = hasThis(sc); auto ad = p ? p.isAggregateDeclaration() : null; if (...) { ... } else e = new TemplateExp(loc, td); // here e = e.semantic(sc); return e; } However in DotIdExp.semanticY, the found TemplateDeclaration is converted to ScopeExp. extern (C++) final class DotIdExp : UnaExp { ... Expression semanticY(Scope* sc, int flag) { ... if (eright.op == TOKimport) { Dsymbol s = ie.sds.search(loc, ident, ...); if (s) { ... ScopeDsymbol sds = s.isScopeDsymbol(); if (sds) { // here, because TemplateDeclaration is derived from ScopeDsymbol //printf("it's a ScopeDsymbol %s\n", ident->toChars()); e = new ScopeExp(loc, sds); e = e.semantic(sc); if (eleft) e = new DotExp(loc, eleft, e); return e; } By this, a TemplateDeclaration handling code should consider both TOKtemplate (TemplateExp) and TOKimport (ScopeExp) in everywhere. It's problematic and bug-prone.
Comment #1 by k.hara.pg — 2015-11-10T02:50:09Z
Today, TOKimport is not properly handled for TemplateDeclaration in some places. Issue 14603 and issue 14604 have been casued by this dmd-internal issue.
Comment #2 by k.hara.pg — 2015-11-10T03:48:04Z
Comment #3 by github-bugzilla — 2016-02-29T17:48:04Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/b48750021ba5fa3f6efe849f219ff4267716b461 fix Issue 15310 - [dmd-internal] TemplateDeclaration should be converted to TemplateExp always Either TemplateExp or ScopeExp was used for a template symbol, but it was problematic.