shithub: mc

Download patch

ref: 9ccb8d4f7a5be8d800ddeb24dd3edc749cad3312
parent: 9954ed6a35cded05c786bc7319a79e20719ea74a
author: Ori Bernstein <[email protected]>
date: Sun Jun 24 10:06:48 EDT 2012

Make returns with 0 args valid.

    'const f = {; ->;}' now compiles without dying.

--- a/8/reduce.c
+++ b/8/reduce.c
@@ -684,7 +684,7 @@
                 u = word(n->line, size(args[0]));
                 v = mkexpr(n->line, Oblit, s->ret, t, u, NULL);
                 append(s, v);
-            } else if (n->expr.args[0]) {
+            } else if (n->expr.nargs && n->expr.args[0]) {
                 t = s->ret;
                 t = store(t, rval(s, args[0]));
                 append(s, t);
--- a/parse/gram.y
+++ b/parse/gram.y
@@ -335,6 +335,8 @@
 retexpr : Tret exprln
             {$$ = mkexpr($1->line, Oret, $2, NULL);}
         | exprln
+        | Tret Tendln
+            {$$ = mkexpr($1->line, Oret, NULL);}
         ;
 
 exprln  : expr Tendln
--- a/parse/infer.c
+++ b/parse/infer.c
@@ -339,6 +339,8 @@
 
     if (n->type != Nexpr)
         return;
+    if (!n->expr.nargs)
+        return;
     args = n->expr.args;
     if (exprop(args[0]) != Ovar)
         return;