ref: 3b0bbade8ba3efecdeea39c2804f65016b3b4831
parent: d36a67129c192ca9092cb9189fca535ed9a63a08
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Jan 24 19:32:57 EST 2015
Error out with invalid specializations. type t(a, b) = ... var x : t(a) will now error correctly.
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -434,6 +434,10 @@
/* If this is an instantiation of a generic type, we want the params to
* match the instantiation */
if (orig->type == Tyunres && isgeneric(t)) {
+ if (t->nparam != orig->narg) {
+ lfatal(orig->loc, "%s incompatibly specialized with %s, declared on %s:%d",
+ tystr(orig), tystr(t), file->file.files[t->loc.file], t->loc.line);
+ }
t = tyfreshen(st, t);
for (i = 0; i < t->narg; i++) {
unify(st, NULL, t->arg[i], orig->arg[i]);