shithub: mc

Download patch

ref: 779bc03ea6bffa543c52a02e6d87e600b0417066
parent: 40a2725c8ac2caae64b232be7be807059671708c
author: Ori Bernstein <[email protected]>
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)