shithub: mc

Download patch

ref: a7f23ccc3e024fd71451c285d9afec55f220d8df
parent: 290709fdfc3fa92e84f9f2bf214c6a144f24c5ee
author: Ori Bernstein <ori@eigenstate.org>
date: Sat Sep 2 13:04:28 EDT 2017

Fix export tagging of traits.

	Sometimes, traits would not get tagged for export transitively.

--- a/parse/export.c
+++ b/parse/export.c
@@ -87,12 +87,19 @@
 				tagtype(st, t->udecls[i]->etype, ingeneric, hidelocal);
 		break;
 	case Tyname:
+	case Tygeneric:
 		tagreflect(t);
 		for (i = 0; i < t->narg; i++)
 			tagtype(st, t->arg[i], ingeneric, hidelocal);
-	case Tygeneric:
 		for (i = 0; i < t->ngparam; i++)
 			tagtype(st, t->gparam[i], ingeneric, hidelocal);
+		for (i = 0; i < t->narg; i++)
+			tagtype(st, t->arg[i], ingeneric, hidelocal);
+		break;
+	case Typaram:
+		if (t->trneed)
+			for (i = 0; bsiter(t->trneed, &i); i++)
+				tagtrait(st, traittab[i], ingeneric, hidelocal);
 		break;
 	default:
 		break;
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -639,8 +639,10 @@
 		popenv(orig->env);
 	} else if (orig->type == Typaram) {
 		tt = boundtype(t);
-		if (tt)
+		if (tt) {
+			tyresolve(tt);
 			t = tt;
+		}
 	}
 	ingeneric -= isgeneric;
 	return t;
@@ -869,8 +871,9 @@
 		ty = base;
 		tm = traitmap->sub[ty->type];
 		while (1) {
-			if (ty->type == Typaram && bshas(ty->trneed, tr->uid))
-				return 1;
+			if (ty->type == Typaram)
+				if (ty->trneed && bshas(ty->trneed, tr->uid))
+					return 1;
 			if (ty->type == Tyvar) {
 				if (!ty->trneed)
 					ty->trneed = mkbs();
@@ -1653,7 +1656,7 @@
 	case Odiveq:	/* @a /= @a -> @a */
 		infersub(n, ret, sawret, &isconst);
 		t = type(args[0]);
-		constrain(n, type(args[0]), traittab[Tcnum]);
+		constrain(n, t, traittab[Tcnum]);
 		isconst = args[0]->expr.isconst;
 		for (i = 1; i < nargs; i++) {
 			isconst = isconst && args[i]->expr.isconst;
@@ -1681,8 +1684,8 @@
 	case Obsreq:	/* @a >>= @a -> @a */
 		infersub(n, ret, sawret, &isconst);
 		t = type(args[0]);
-		constrain(n, type(args[0]), traittab[Tcnum]);
-		constrain(n, type(args[0]), traittab[Tcint]);
+		constrain(n, t, traittab[Tcnum]);
+		constrain(n, t, traittab[Tcint]);
 		isconst = args[0]->expr.isconst;
 		for (i = 1; i < nargs; i++) {
 			isconst = isconst && args[i]->expr.isconst;