From d872976cb9de78de92a18079b9b90adfd502b7d9 Mon Sep 17 00:00:00 2001 From: k-hara Date: Thu, 21 Nov 2013 14:22:28 +0900 Subject: [PATCH] fix Issue 10938 - ICE on recursive instantiation in opDispatch By fixing issue 10736 (314a1cca9ff56775b9e2a9cf81564135be0726b1), all of template instance semantic are reliably finished by the deferred mechanism. And it had removed the necessity of the code in `DotTemplateInstanceExp::semanticY` for the issue 4003. Therefore, just remove the unnecessary code to fix the ICE. --- src/expression.c | 19 ------------------- test/fail_compilation/ice10938.d | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 19 deletions(-) create mode 100644 test/fail_compilation/ice10938.d diff --git a/src/expression.c b/src/expression.c index 79ee88c951ed..0c0ffeffbc4f 100644 --- a/src/expression.c +++ b/src/expression.c @@ -8161,25 +8161,6 @@ Expression *DotTemplateInstanceExp::semanticY(Scope *sc, int flag) Declaration *v = s->isDeclaration(); if (v && (v->isFuncDeclaration() || v->isVarDeclaration())) { - /* Fix for Bugzilla 4003 - * The problem is a class template member function v returning a reference to the same - * type as the enclosing template instantiation. This results in a nested instantiation, - * which of course gets short circuited. The return type then gets set to - * the template instance type before instantiation, rather than after. - * We can detect this by the deco not being set. If so, go ahead and retry - * the return type semantic. - * The offending code is the return type from std.typecons.Tuple.slice: - * ref Tuple!(Types[from .. to]) slice(uint from, uint to)() - * { - * return *cast(typeof(return) *) &(field[from]); - * } - * and this line from the following unittest: - * auto s = a.slice!(1, 3); - * where s's type wound up not having semantic() run on it. - */ - if (v->type && !v->type->deco) - v->type = v->type->semantic(v->loc, sc); - e = new DotVarExp(loc, eleft, v); e = e->semantic(sc); return e; diff --git a/test/fail_compilation/ice10938.d b/test/fail_compilation/ice10938.d new file mode 100644 index 000000000000..2b3eab52ea3f --- /dev/null +++ b/test/fail_compilation/ice10938.d @@ -0,0 +1,23 @@ +/* +TEST_OUTPUT: +--- +fail_compilation/ice10938.d(12): Error: no property 'opts' for type 'ice10938.C' +--- +*/ + +class C +{ + this() + { + this.opts["opts"] = 1; + } + + auto opDispatch(string field : "opts")() + { + return this.opts; // ICE -> compile time error + } +} + +void main() +{ +}