Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Issue 9406 - (Regression: 2.061) Stack overflow from a forward reference error #1576

Merged
merged 2 commits into from

2 participants

Hara Kenji Walter Bright
9rnsr added some commits
Hara Kenji 9rnsr fix Issue 9406 - (Regression: 2.061) Stack overflow from a forward re…
…ference error
fb0aca7
Hara Kenji 9rnsr Fix unnecessary forward reference error.
In DotTemplateInstanceExp, needsTypeInference is used to determine whether the instance is really a function call or not. But the template is yet not actually instantiated, so onemember->toAlias() might fail. In this case, TemplateInstance::toAlias() tried to run its semantic.
2f20199
Walter Bright WalterBright merged commit 6bb0a54 into from
Deleted user Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Deleted user Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Deleted user Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Deleted user Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 29, 2013
  1. Hara Kenji
  2. Hara Kenji

    Fix unnecessary forward reference error.

    9rnsr authored
    In DotTemplateInstanceExp, needsTypeInference is used to determine whether the instance is really a function call or not. But the template is yet not actually instantiated, so onemember->toAlias() might fail. In this case, TemplateInstance::toAlias() tried to run its semantic.
This page is out of date. Refresh to see the latest.
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!();
+}
Something went wrong with that request. Please try again.