summaryrefslogtreecommitdiff
path: root/parse
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
parentc5245eaa80064b77186fa286f8e5e8bca73309ab (diff)
downloadmc-9a2f63d47a96bf522e6c5d39e215b2e6a9e600c7.tar.gz
Fix error message for generics in non-generic decls.
Diffstat (limited to 'parse')
-rw-r--r--parse/infer.c11
-rw-r--r--parse/parse.h2
-rw-r--r--parse/type.c2
3 files changed, 5 insertions, 10 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);
diff --git a/parse/parse.h b/parse/parse.h
index 90fd2fe..3dc79ba 100644
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -419,8 +419,6 @@ Tyenv *mkenv(void);
Tyenv *curenv(void);
void pushenv(Tyenv *e);
void popenv(Tyenv *e);
-void _tybind(Tyenv *e, Type *t);
-void _bind(Tyenv *e, Node *n);
/* type creation */
void tyinit(Stab *st); /* sets up built in types */
diff --git a/parse/type.c b/parse/type.c
index 82b45ba..bba8f29 100644
--- a/parse/type.c
+++ b/parse/type.c
@@ -417,7 +417,7 @@ hasparamsrec(Type *t, Bitset *visited)
return 0;
bsput(visited, t->tid);
switch (t->type) {
- case Typaram:
+ case Typaram: return 1;
case Tygeneric: return 1;
case Tyname:
for (i = 0; i < t->narg; i++)