shithub: mc

Download patch

ref: 444b77956c15d1895a64891ca16f8313fdb00b9c
parent: 0de1c881850c5fec2183b2e59cd10b8931cd93a4
author: Ori Bernstein <[email protected]>
date: Fri Sep 22 08:10:15 EDT 2017

Fix trait lookup for nested pointers.

--- a/parse/infer.c
+++ b/parse/infer.c
@@ -895,11 +895,13 @@
 				if (tymatchrank(tm->filter[i], ty) >= 0)
 					return 1;
 			}
-			if (!tm->sub[ty->type])
-				break;
 			assert(ty->nsub == 1);
-			tm = tm->sub[ty->type];
+			if (!ty->sub)
+				break;
 			ty = ty->sub[0];
+			tm = tm->sub[ty->type];
+			if (!tm)
+				break;
 		}
 		if (base->type != Tyname)
 			break;
@@ -2813,7 +2815,7 @@
 	size_t i;
 
 	if (!m->sub[ty->type])
-		m = mktraitmap();
+		m->sub[ty->type] = mktraitmap();
 	mm = m->sub[ty->type];
 	switch (ty->type) {
 	case Tygeneric:
--- /dev/null
+++ b/test/pkgtrait.myr
@@ -1,0 +1,13 @@
+use std
+use regex
+
+impl disposable regex.regex# =
+	__dispose__ = {r
+		regex.free(r)
+	}
+;;
+
+const main = {
+	var auto r : regex.regex#
+	r = std.try(regex.compile(".*"))
+}
--- a/test/tests
+++ b/test/tests
@@ -86,6 +86,7 @@
 B generic	E	42
 B genericval	E	42
 B trait-builtin	E	42
+B pkgtrait	E	42
 B gtrait	P	'`std.Before '
 B emptytrait	E	123
 B traitimpl	P	246,44,meee