shithub: mc

Download patch

ref: 49b61a099de4734e638b1122a5542dd616edd462
parent: 321aec6bf2b82698196a94725e37cee135b1fe2b
author: Mura Li <mura_li@castech.com.tw>
date: Wed Apr 22 03:00:16 EDT 2020

Fix wrong order of recursive calls

Also, improve slightly the error messages.

--- a/mi/match.c
+++ b/mi/match.c
@@ -458,9 +458,9 @@
 	pat = fold(pat, 1);
 	switch (exprop(pat)) {
 	case Olor:
-		addrec(fs, pat->expr.args[1], val, path);
 		next = frontierdup(fs);
 		fs->next = next;
+		addrec(fs, pat->expr.args[1], val, path);
 		addrec(next, pat->expr.args[0], val, path);
 		break;
 	case Ogap:
@@ -938,10 +938,10 @@
 		cur = frontier[i];
 		if (last && last->i == cur->i) {
 			if (last->ncap != cur->ncap)
-				fatal(pat[cur->i], "captured variables are not equally bound in all or-pattern of the same group");
+				fatal(pat[cur->i], "number of wildcard variables in the or-patterns are not equal (%d != %d)", last->ncap, cur->ncap);
 			for (j = 0; j < cur->ncap; j++) {
 				if (!capeq(last->cap[j], cur->cap[j]))
-					fatal(pat[cur->i], "captured variables are not equally bound in all or-pattern of the same group");
+					fatal(pat[cur->i], "wildcard variables have different types in the or-patterns");
 			}
 		} else {
 			addcapture(pat[cur->i]->match.block, cur->cap, cur->ncap);