summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-08-02 23:17:18 -0700
committerOri Bernstein <ori@eigenstate.org>2017-08-02 23:17:18 -0700
commit63d9419c6b72ef4ba813b0e8c6f234b9ab843d27 (patch)
treee07dbfc1edb3046e0ccd60b4cc7cdac3df5dfa5f
parentcfd9043ca984976e85b1cfffc0519d9b08f14713 (diff)
downloadmc-63d9419c6b72ef4ba813b0e8c6f234b9ab843d27.tar.gz
Disallow types of the form `type t = t`.
This is an infinite loop, and is not meaningful.
-rw-r--r--parse/infer.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/parse/infer.c b/parse/infer.c
index 6c7a1a2..837535e 100644
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -507,8 +507,14 @@ tyresolve(Type *t)
break;
}
- for (i = 0; i < t->nsub; i++)
+ for (i = 0; i < t->nsub; i++) {
t->sub[i] = tf(t->sub[i]);
+ if (t->sub[i] == t) {
+ lfatal(t->loc,
+ "%s occurs within %s, leading to infinite type\n",
+ tystr(t->sub[i]), tystr(t));
+ }
+ }
base = tybase(t);
/* no-ops if base == t */
if (t->traits && base->traits)