shithub: mc

Download patch

ref: 28a09414d4f8ec3aa8961c079a4fc13081beb34e
parent: b778de26a0bcc80aa49f111b8333511511073634
author: Ori Bernstein <ori@eigenstate.org>
date: Wed Dec 30 15:48:15 EST 2015

Don't double-infer nodes.

	This was leading to us deciding that variables double declared.

--- a/mi/fold.c
+++ b/mi/fold.c
@@ -217,7 +217,7 @@
 		t = tybase(exprtype(args[0]));
 		/* we only fold lengths right now */
 		if (t->type == Tyarray && !strcmp(namestr(args[1]), "len")) {
-			r = mkexpr(n->loc, Ocast, t->asize);
+			r = t->asize;
 			r->expr.type = exprtype(n);
 		}
 		break;
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -26,6 +26,9 @@
 	/* bound by patterns turn into decls in the action block */
 	Node **binds;
 	size_t nbinds;
+	/* bound by patterns turn into decls in the action block */
+	Node **impldecl;
+	size_t nimpldecl;
 	/* nodes that need post-inference checking/unification */
 	Node **postcheck;
 	size_t npostcheck;
@@ -1658,7 +1661,7 @@
 					namestr(proto->decl.name), tystr(type(st, proto)), namestr(name),
 					tystr(ty));
 		dcl->decl.vis = t->vis;
-		lappend(&file->file.stmts, &file->file.nstmts, dcl);
+		lappend(&st->impldecl, &st->nimpldecl, dcl);
 	}
 }
 
@@ -2435,6 +2438,12 @@
 {
 	Node *d, *name;
 	size_t i;
+
+	for (i = 0; i < st->nimpldecl; i++) {
+		d = st->impldecl[i];
+		lappend(&file->file.stmts, &file->file.nstmts, d);
+		typesub(st, d, 0);
+	}
 
 	for (i = 0; i < st->nspecializations; i++) {
 		pushstab(st->specializationscope[i]);