summaryrefslogtreecommitdiff
path: root/parse/infer.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2017-07-28 23:36:36 -0700
committerOri Bernstein <ori@eigenstate.org>2017-07-28 23:36:36 -0700
commit9a2f63d47a96bf522e6c5d39e215b2e6a9e600c7 (patch)
tree0cca01cbe1cb16b56479f6081c8275bd1df975cc /parse/infer.c
parentc5245eaa80064b77186fa286f8e5e8bca73309ab (diff)
downloadmc-9a2f63d47a96bf522e6c5d39e215b2e6a9e600c7.tar.gz
Fix error message for generics in non-generic decls.
Diffstat (limited to 'parse/infer.c')
-rw-r--r--parse/infer.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/parse/infer.c b/parse/infer.c
index fc6e13e..2113961 100644
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -734,7 +734,9 @@ satisfiestraits(Type *a, Type *b)
{
if (!a->traits || bscount(a->traits) == 0)
return 1;
- return bsissubset(a->traits, b->traits);
+ if (b->traits)
+ return bsissubset(a->traits, b->traits);
+ return 0;
}
static void
@@ -1297,7 +1299,6 @@ inferucon(Node *n, int *isconst)
*
* To make it compile, for now, we just bind the types in here.
*/
- //tybindall(uc->utype);
t = tysubst(tf(uc->utype), uc->utype);
uc = tybase(t)->udecls[uc->id];
if (uc->etype) {
@@ -1306,7 +1307,6 @@ inferucon(Node *n, int *isconst)
*isconst = n->expr.args[1]->expr.isconst;
}
settype(n, delayeducon(t));
- //tyunbind();
}
static void
@@ -1623,10 +1623,7 @@ inferexpr(Node **np, Type *ret, int *sawret)
infersub(n, ret, sawret, &isconst);
switch (args[0]->lit.littype) {
case Lfunc:
- //tybindall(args[0]->lit.fnval->func.type);
infernode(&args[0]->lit.fnval, NULL, NULL);
- //tyunbind();
-
/* FIXME: env capture means this is non-const */
n->expr.isconst = 1;
break;
@@ -1876,7 +1873,7 @@ infernode(Node **np, Type *ret, int *sawret)
setsuperenv(n->decl.env, curenv());
pushenv(n->decl.env);
inferdecl(n);
- if (type(n)->type == Typaram && !ingeneric)
+ if (hasparams(type(n)) && !ingeneric)
fatal(n, "generic type %s in non-generic near %s", tystr(type(n)),
ctxstr(n));
popenv(n->decl.env);