summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-12-15 00:53:20 -0800
committerOri Bernstein <ori@eigenstate.org>2015-12-15 00:53:20 -0800
commita80975b0c347277095c091650daaa8a18ad67702 (patch)
treeb6e433110998b182172aaeb5abd1bec5200d3fdc
parent3aec3caf0f75feec908fca6e387e7d50ae208d33 (diff)
downloadmc-a80975b0c347277095c091650daaa8a18ad67702.tar.gz
Allow matching a single void.
Void has 1 constructor, not 0.
-rw-r--r--mi/match.c5
-rw-r--r--parse/infer.c3
2 files changed, 4 insertions, 4 deletions
diff --git a/mi/match.c b/mi/match.c
index bfca0a6..deac3e6 100644
--- a/mi/match.c
+++ b/mi/match.c
@@ -165,7 +165,7 @@ static size_t nconstructors(Type *t)
t = tybase(t);
switch (t->type) {
- case Tyvoid: return 0; break;
+ case Tyvoid: return 1; break;
case Tybool: return 2; break;
case Tychar: return 0x10ffff; break;
@@ -338,6 +338,9 @@ static int addwildrec(Srcloc loc, Type *ty, Dtree *start, Dtree *accept, Dtree *
ret = acceptall(start, accept);
lappend(&last, &nlast, accept);
break;
+ case Tyvoid:
+ ret = 1;
+ break;
default:
lappend(&last, &nlast, accept);
break;
diff --git a/parse/infer.c b/parse/infer.c
index 6894a1c..b305d77 100644
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -1740,9 +1740,6 @@ static void infernode(Inferstate *st, Node **np, Type *ret, int *sawret)
break;
case Nmatchstmt:
infernode(st, &n->matchstmt.val, NULL, sawret);
- if (tybase(type(st, n->matchstmt.val))->type == Tyvoid)
- fatal(n, "can't match against a void type near %s",
- ctxstr(st, n->matchstmt.val));
for (i = 0; i < n->matchstmt.nmatches; i++) {
infernode(st, &n->matchstmt.matches[i], ret, sawret);
pat = n->matchstmt.matches[i]->match.pat;