Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #1576 from 9rnsr/fix9406

Issue 9406 - (Regression: 2.061) Stack overflow from a forward reference error
  • Loading branch information...
commit 6bb0a54cb8656c6debaac733118036ec3f48bbc6 2 parents 274dacf + 2f20199
Walter Bright WalterBright authored
Showing with 28 additions and 4 deletions.
  1. +6 −4 src/template.c
  2. +22 −0 test/fail_compilation/ice9406.d
10 src/template.c
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.
22 test/fail_compilation/ice9406.d
View
@@ -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!();
+}
Please sign in to comment.
Something went wrong with that request. Please try again.