shithub: mc

Download patch

ref: eac5baa8515b5e6fe46ecf609d2cac94ffed5dc6
parent: 2a27b2d8ac101e17e300a2e25421fc25c403b05b
author: Ori Bernstein <[email protected]>
date: Thu Nov 5 20:38:19 EST 2015

Fix patterns with multiple sequential wildcards

    (a, b) was an invalid pattern, since we would never
    generate the jump to the pattern check for b.

--- a/mi/match.c
+++ b/mi/match.c
@@ -692,8 +692,12 @@
         if (emit)
             lappend(out, nout, fail);
     }
-    if (dt->any)
+    if (dt->any) {
+        jmp = mkexpr(dt->loc, Ojmp, dt->any->lbl, NULL);
+        jmp->expr.type = mktype(dt->loc, Tyvoid);
+        lappend(out, nout, jmp);
         genmatchcode(dt->any, out, nout);
+    }
 }
 
 void genonematch(Node *pat, Node *val, Node *iftrue, Node *iffalse, Node ***out, size_t *nout, Node ***cap, size_t *ncap)
@@ -743,9 +747,11 @@
     }
     lappend(out, nout, endlbl);
     
-    //dtreedump(stdout, dt);
-    //for (i = 0; i < *nout; i++)
-    //    dump((*out)[i], stdout);
+    if (debugopt['m']) {
+        dtreedump(stdout, dt);
+        for (i = 0; i < *nout; i++)
+            dump((*out)[i], stdout);
+    }
 }