From 22ff2a531015b5330b9a095f028dc87e80df8fb2 Mon Sep 17 00:00:00 2001 From: k-hara Date: Tue, 16 Sep 2014 04:43:43 +0900 Subject: [PATCH] fix Issue 13479 - Templates not emitted when instantiated in mixins mixed in functions In the PR #3948, I changed the position where `TemplateInstance`s are inserted. https://github.com/D-Programming-Language/dmd/pull/3948/files#diff-0477a1d81a6a920c99362954179c59c8R5937 But, I didn't notice that glue-layer does not handle `TemplateInstance`s in local members. --- src/e2ir.c | 6 +++++- test/runnable/mixin2.d | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/e2ir.c b/src/e2ir.c index d91171246d5f..f1a27f0829fb 100644 --- a/src/e2ir.c +++ b/src/e2ir.c @@ -1091,7 +1091,7 @@ elem *toElem(Expression *e, IRState *irs) void visit(DeclarationExp *de) { - //printf("DeclarationExp::toElem() %s\n", detoChars()); + //printf("DeclarationExp::toElem() %s\n", de->toChars()); result = Dsymbol_toElem(de->declaration); } @@ -4826,6 +4826,10 @@ elem *toElem(Expression *e, IRState *irs) { irs->deferToObj->push(ed); } + else if (TemplateInstance *ti = s->isTemplateInstance()) + { + irs->deferToObj->push(ti); + } return e; } diff --git a/test/runnable/mixin2.d b/test/runnable/mixin2.d index c50c35666d1c..861cb23cd4b5 100644 --- a/test/runnable/mixin2.d +++ b/test/runnable/mixin2.d @@ -324,6 +324,24 @@ void test7553() auto r2 = new Bar7553().to_range(1); } +/*********************************************/ +// 13479 + +mixin template F13479() +{ + void t()() + { + } + + alias t!() a; +} + +void test13479() +{ + mixin F13479!(); + a(); +} + /*********************************************/ void main() @@ -339,6 +357,7 @@ void main() test9(); test10(); test7156(); + test13479(); writeln("Success"); }