Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Issue 9494 - Error on recursive associative array declaration. #1662

Merged
merged 2 commits into from

2 participants

@ghost

LGTM.

@9rnsr 9rnsr merged commit d20ac55 into D-Programming-Language:master
@9rnsr 9rnsr deleted the 9rnsr:fix9494 branch
@ghost Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@ghost Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@ghost Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@ghost Unknown referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@CyberShadow

This commit introduced a possible regression:
https://issues.dlang.org/show_bug.cgi?id=12571

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
2  src/declaration.c
@@ -878,7 +878,9 @@ void VarDeclaration::semantic(Scope *sc)
else
{ if (!originalType)
originalType = type->syntaxCopy();
+ inuse++;
type = type->semantic(loc, sc);
+ inuse--;
}
//printf(" semantic type = %s\n", type ? type->toChars() : "null");
View
18 src/mtype.c
@@ -6640,6 +6640,11 @@ void TypeQualified::resolveHelper(Loc loc, Scope *sc,
v = s->isVarDeclaration();
if (v)
{
+ if (v && v->inuse && (!v->type || !v->type->deco)) // Bugzilla 9494
+ { error(loc, "circular reference to '%s'", v->toPrettyChars());
+ *pe = new ErrorExp();
+ return;
+ }
*pe = new VarExp(loc, v);
return;
}
@@ -8087,6 +8092,10 @@ Expression *TypeStruct::dotExp(Scope *sc, Expression *e, Identifier *ident)
s = s->toAlias();
v = s->isVarDeclaration();
+ if (v && v->inuse && (!v->type || !v->type->deco)) // Bugzilla 9494
+ { e->error("circular reference to '%s'", v->toPrettyChars());
+ return new ErrorExp();
+ }
if (v && !v->isDataseg())
{
Expression *ei = v->getConstInitializer();
@@ -8687,10 +8696,15 @@ Expression *TypeClass::dotExp(Scope *sc, Expression *e, Identifier *ident)
if (!s->isFuncDeclaration()) // because of overloading
s->checkDeprecated(e->loc, sc);
s = s->toAlias();
+
v = s->isVarDeclaration();
+ if (v && v->inuse && (!v->type || !v->type->deco)) // Bugzilla 9494
+ { e->error("circular reference to '%s'", v->toPrettyChars());
+ return new ErrorExp();
+ }
if (v && !v->isDataseg())
- { Expression *ei = v->getConstInitializer();
-
+ {
+ Expression *ei = v->getConstInitializer();
if (ei)
{ e = ei->copy(); // need to copy it if it's a StringExp
e = e->semantic(sc);
View
19 test/fail_compilation/ice4094.d
@@ -0,0 +1,19 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/ice4094.d(11): Error: circular reference to 'ice4094.Zug!(0).Zug.bahn'
+fail_compilation/ice4094.d(19): Error: template instance ice4094.Zug!(0) error instantiating
+---
+*/
+
+struct Zug(int Z)
+{
+ const bahn = Bug4094!(0).hof.bahn;
+}
+
+struct Bug4094(int Q)
+{
+ Zug!(0) hof;
+}
+
+const a = Zug!(0).bahn;
View
20 test/fail_compilation/ice9494.d
@@ -0,0 +1,20 @@
+/*
+TEST_OUTPUT:
+---
+fail_compilation/ice9494.d(10): Error: circular reference to 'ice9494.test'
+fail_compilation/ice9494.d(14): Error: circular reference to 'ice9494.Foo.test'
+fail_compilation/ice9494.d(19): Error: circular reference to 'ice9494.Bar.test'
+---
+*/
+
+int[test] test; // stack overflow
+
+class Foo
+{
+ int[this.test] test; // stack overflow
+}
+
+struct Bar
+{
+ int[this.test] test; // stack overflow
+}
Something went wrong with that request. Please try again.