Skip to content

Commit

Permalink
fix Issue 10938 - ICE on recursive instantiation in opDispatch
Browse files Browse the repository at this point in the history
By fixing issue 10736 (314a1cc), 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.
  • Loading branch information
9rnsr committed Dec 31, 2013
1 parent 79f0913 commit d872976
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
19 changes: 0 additions & 19 deletions src/expression.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
23 changes: 23 additions & 0 deletions test/fail_compilation/ice10938.d
Original file line number Diff line number Diff line change
@@ -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()
{
}

0 comments on commit d872976

Please sign in to comment.