shithub: mc

Download patch

ref: f5175435a735fa8cdcd28995d5f3e32faf792945
parent: e3682d0bb7437dc3cbb6a6fcf8d82806d98c73da
author: Mura Li <mural@ctli.io>
date: Mon Jul 5 09:39:04 EDT 2021

mi/match: fix dtree construction order of or-pattern
When we have a match statement such as
    match x
    | `std.Some _ || _:
    ;;

the order of the patterns `std.seom _ and _ matters.
before the fix, we would get false positive of "pattern
matched by earlier case".

Signed-off-by: Mura Li <mural@ctli.io>

--- a/mi/match.c
+++ b/mi/match.c
@@ -464,8 +464,8 @@
 		next->hasorpat = 1;
 		fs->next = next;
 		fs->hasorpat = 1;
-		addrec(fs, pat->expr.args[1], val, path);
-		addrec(next, pat->expr.args[0], val, path);
+		addrec(fs, pat->expr.args[0], val, path);
+		addrec(next, pat->expr.args[1], val, path);
 		break;
 	case Ogap:
 		lappend(&fs->slot, &fs->nslot, mkslot(path, pat, val));