shithub: mc

Download patch

ref: 3aec3caf0f75feec908fca6e387e7d50ae208d33
parent: 994b042eac3300dd62bbbc7dedbb6d9a0b525638
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Dec 14 19:20:39 EST 2015

Fix matching void union args.

	We no longer segfault! Whee!

--- a/6/simp.c
+++ b/6/simp.c
@@ -256,6 +256,9 @@
 
 	assert(a != NULL && b != NULL);
 	assert(exprop(a) == Ovar || exprop(a) == Oderef);
+	if (tybase(exprtype(a))->type == Tyvoid)
+		return a;
+
 	n = mkexpr(a->loc, Oset, a, b, NULL);
 	n->expr.type = exprtype(a);
 	return n;
--- a/test/tests
+++ b/test/tests
@@ -106,6 +106,7 @@
 B matchstruct	E	42
 B matcharray	E	42
 B matchargunion	E	69
+B matchvoid	E	'ok'
 B matchexhaust	P	worked
 B matchargstr	C
 B matchunion_sl	P	foo
--- /dev/null
+++ b/test/voidmatch.myr
@@ -1,0 +1,8 @@
+use std
+
+const main = {
+	match `std.Some void
+	| `std.Some x:	std.put("ok\n")
+	| `std.None:	std.put("fail\n")
+	;;
+}