shithub: mc

Download patch

ref: 5162ad233581d7fc5097501f6163321741174890
parent: 95fc77c94bec1b7e1d3df3abd6706bec795225e0
parent: ae909b89c7b655a8bf943992c4fdd74707860140
author: Ori Bernstein <[email protected]>
date: Thu Sep 26 22:44:52 EDT 2013

Merge ../mc

--- a/parse/infer.c
+++ b/parse/infer.c
@@ -981,8 +981,14 @@
         case Osub:      /* @a - @a -> @a */
         case Omul:      /* @a * @a -> @a */
         case Odiv:      /* @a / @a -> @a */
-        case Omod:      /* @a % @a -> @a */
         case Oneg:      /* -@a -> @a */
+            t = type(st, args[0]);
+            constrain(st, n, type(st, args[0]), cstrtab[Tcnum]);
+            for (i = 1; i < nargs; i++)
+                t = unify(st, n, t, type(st, args[i]));
+            settype(st, n, tf(st, t));
+            break;
+        case Omod:      /* @a % @a -> @a */
         case Obor:      /* @a | @a -> @a */
         case Oband:     /* @a & @a -> @a */
         case Obxor:     /* @a ^ @a -> @a */
@@ -993,7 +999,6 @@
         case Opredec:   /* --@a -> @a */
         case Opostinc:  /* @a++ -> @a */
         case Opostdec:  /* @a-- -> @a */
-        case Oasn:      /* @a = @a -> @a */
         case Oaddeq:    /* @a += @a -> @a */
         case Osubeq:    /* @a -= @a -> @a */
         case Omuleq:    /* @a *= @a -> @a */
@@ -1004,6 +1009,14 @@
         case Obxoreq:   /* @a ^= @a -> @a */
         case Obsleq:    /* @a <<= @a -> @a */
         case Obsreq:    /* @a >>= @a -> @a */
+            t = type(st, args[0]);
+            constrain(st, n, type(st, args[0]), cstrtab[Tcnum]);
+            constrain(st, n, type(st, args[0]), cstrtab[Tcint]);
+            for (i = 1; i < nargs; i++)
+                t = unify(st, n, t, type(st, args[i]));
+            settype(st, n, tf(st, t));
+            break;
+        case Oasn:      /* @a = @a -> @a */
             t = type(st, args[0]);
             for (i = 1; i < nargs; i++)
                 t = unify(st, n, t, type(st, args[i]));
--- /dev/null
+++ b/test/badop.myr
@@ -1,0 +1,6 @@
+use std
+
+const main = {
+	var x
+	x = "a" + "b"
+}
--- a/test/tests
+++ b/test/tests
@@ -103,3 +103,4 @@
 F generic-in-const
 F aritylow
 F arityhigh
+F badop