ref: 63d9419c6b72ef4ba813b0e8c6f234b9ab843d27
parent: cfd9043ca984976e85b1cfffc0519d9b08f14713
author: Ori Bernstein <ori@eigenstate.org>
date: Wed Aug 2 19:17:18 EDT 2017
Disallow types of the form `type t = t`. This is an infinite loop, and is not meaningful.
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -507,8 +507,14 @@
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)