Permalink
Browse files

Merge pull request #1576 from 9rnsr/fix9406

Issue 9406 - (Regression: 2.061) Stack overflow from a forward reference error
  • Loading branch information...
2 parents 274dacf + 2f20199 commit 6bb0a54cb8656c6debaac733118036ec3f48bbc6 @WalterBright WalterBright committed Jan 29, 2013
Showing with 28 additions and 4 deletions.
  1. +6 −4 src/template.c
  2. +22 −0 test/fail_compilation/ice9406.d
View
@@ -2432,9 +2432,11 @@ char *TemplateDeclaration::toChars()
}
buf.writeByte(')');
- if (onemember && onemember->toAlias())
- {
- FuncDeclaration *fd = onemember->toAlias()->isFuncDeclaration();
+ if (onemember)
+ { /* Bugzilla 9406:
+ * onemember->toAlias() might run semantic, so should not call it in stringizing
+ */
+ FuncDeclaration *fd = onemember->isFuncDeclaration();
if (fd && fd->type)
{
TypeFunction *tf = (TypeFunction *)fd->type;
@@ -5988,7 +5990,7 @@ int TemplateInstance::needsTypeInference(Scope *sc)
*/
FuncDeclaration *fd;
if (!td->onemember ||
- (fd = td->onemember->toAlias()->isFuncDeclaration()) == NULL ||
+ (fd = td->onemember/*->toAlias()*/->isFuncDeclaration()) == NULL ||
fd->type->ty != Tfunction)
{
/* Not a template function, therefore type inference is not possible.
@@ -0,0 +1,22 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/ice9406.d(21): Error: expression has no value
+---
+*/
+
+mixin template Mixin() { }
+
+struct S
+{
+ template t1()
+ {
+ mixin Mixin t1;
+ }
+}
+
+void main()
+{
+ S s1;
+ s1.t1!();
+}

0 comments on commit 6bb0a54

Please sign in to comment.