shithub: mc

Download patch

ref: f52bd3e4ab5dd49a6ca4562bce9b49b226721805
parent: fa746541e9aaf06de5b4c6c87f38703c128f165b
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Sep 23 09:04:46 EDT 2014

Don't mark namespaced variable lvalues as const.

    Reading a var is pure, but the var itself isn't const.

--- a/parse/infer.c
+++ b/parse/infer.c
@@ -1202,9 +1202,11 @@
             isconst = isconst && args[i]->expr.isconst;
         }
     }
-    if (ispureop[exprop(n)])
+    if (exprop(n) == Ovar)
+        n->expr.isconst = decls[n->expr.did]->decl.isconst;
+    else if (ispureop[exprop(n)])
         n->expr.isconst = isconst;
-    *exprconst = isconst;
+    *exprconst = n->expr.isconst;
 }
 
 static void inferexpr(Inferstate *st, Node *n, Type *ret, int *sawret)