shithub: mc

Download patch

ref: a54d7deb4b5cdc397f1e5cf3957edc0b91f5f880
parent: d5ade40b51092a405c0ee44b63a461409de20371
author: Ori Bernstein <ori@eigenstate.org>
date: Sun Jun 25 19:51:13 EDT 2017

Fix some actual type bugs.

	Strictness fixes issues. Oops.

--- a/lib/bio/bio.myr
+++ b/lib/bio/bio.myr
@@ -13,7 +13,7 @@
 
 		read	: (buf : byte[:] -> std.result(std.size, std.errno))
 		write	: (buf : byte[:] -> std.result(std.size, std.errno))
-		seek	: (idx : std.off -> std.result(std.size, std.errno))
+		seek	: (idx : std.off -> std.result(std.off, std.errno))
 		close	: (-> void)
 
 		/* read buffer */
@@ -29,7 +29,7 @@
 	type vtab = struct
 		read	: (buf : byte[:] -> std.result(std.size, std.errno))
 		write	: (buf : byte[:] -> std.result(std.size, std.errno))
-		seek	: (idx : std.off -> std.result(std.size, std.errno))
+		seek	: (idx : std.off -> std.result(std.off, std.errno))
 		close	: (-> void)
 	;;
 
--- a/lib/bio/mem.myr
+++ b/lib/bio/mem.myr
@@ -21,7 +21,7 @@
 	-> mk(Rd, [
 		.read = {buf; -> memread(mem, buf)},
 		.write = {buf; -> memwrite(mem, buf)},
-		.seek = {off; mem.off = std.clamp(off, 0, mem.buf.len); -> `std.Ok mem.off},
+		.seek = {off; -> memseek(mem, off)},
 		.close = {; std.free(mem)},
 	])
 }
@@ -42,4 +42,10 @@
 	std.slcp(mem.buf[mem.off:mem.off+n], src[:n])
 	mem.off += n
 	-> `std.Ok n
+}
+
+const memseek = {mem, off : std.off
+	off = std.clamp(off, 0, mem.buf.len)
+	mem.off = (off : std.size)
+	-> `std.Ok off
 }
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -1071,7 +1071,7 @@
 	 * Otherwise, match up subtypes. */
 	if (a->type == b->type && a->type != Tyvar) {
 		if (a->type == Tyname)
-			if (a->tid != b->tid)
+			if (!nameeq(a->name, b->name))
 				typeerror(st, a, b, ctx, "incompatible types");
 		if (hasargs(a) && hasargs(b)) {
 			/* Only Tygeneric and Tyname should be able to unify. And they