ref: a80975b0c347277095c091650daaa8a18ad67702
parent: 3aec3caf0f75feec908fca6e387e7d50ae208d33
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Dec 14 19:53:20 EST 2015
Allow matching a single void. Void has 1 constructor, not 0.
--- a/mi/match.c
+++ b/mi/match.c
@@ -165,7 +165,7 @@
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;
@@ -337,6 +337,9 @@
case Tyslice:
ret = acceptall(start, accept);
lappend(&last, &nlast, accept);
+ break;
+ case Tyvoid:
+ ret = 1;
break;
default:
lappend(&last, &nlast, accept);
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -1740,9 +1740,6 @@
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;