shithub: mc

Download patch

ref: 10693cab889e841aa758da1f6fd5fe5148510672
parent: a2b0e52ef65d87927a887617898d70aa83feb45c
author: Ori Bernstein <[email protected]>
date: Fri Jul 27 10:56:05 EDT 2012

Fix slice type inference a bit

    We were looking at the wrong arg.

--- a/parse/infer.c
+++ b/parse/infer.c
@@ -572,9 +572,11 @@
             settype(st, n, tf(st, t->sub[0]));
             break;
         case Oslice:    /* @a[@b::tcint,@b::tcint] -> @a[,] */
-            t = mktyidxhack(n->line, type(st, args[1]));
+            t = mktyidxhack(n->line, mktyvar(n->line));
             unify(st, n, type(st, args[0]), t);
-            settype(st, n, mktyslice(n->line, type(st, args[1])));
+            constrain(st, n, type(st, args[1]), cstrtab[Tcint]);
+            constrain(st, n, type(st, args[2]), cstrtab[Tcint]);
+            settype(st, n, mktyslice(n->line, tf(st, t->sub[0])));
             break;
 
         /* special cases */