shithub: mc

Download patch

ref: 468265b7b2719d783afc46ea5aa7c9ffa3142970
parent: 052d543c45844d9a34312c81baa6b665c80ab19f
author: Ori Bernstein <ori@eigenstate.org>
date: Tue Jan 6 06:03:36 EST 2015

Error out when passing void as a function argument.

--- a/parse/infer.c
+++ b/parse/infer.c
@@ -794,6 +794,10 @@
     } else if (tybase(ft)->type != Tyfunc) {
         fatal(n, "calling uncallable type %s", tystr(ft));
     }
+    /* first arg: function itself */
+    for (i = 1; i < n->expr.nargs; i++)
+        if (exprtype(n->expr.args[i])->type == Tyvoid)
+            fatal(n, "void passed where value expected, near %s", ctxstr(st, n));
     for (i = 1; i < n->expr.nargs; i++) {
         if (i == ft->nsub)
             fatal(n, "%s arity mismatch (expected %zd args, got %zd)",