shithub: mc

Download patch

ref: 18386e4095db52452505a6855117ca80a349be60
parent: 46bd46258ef5ead2de06c57fcda29c736f1aeda9
author: Ori Bernstein <[email protected]>
date: Thu Apr 30 15:40:20 EDT 2015

Don't stop inferring structs early.

    We were erroring where we should have been leaving things alone.

--- a/parse/infer.c
+++ b/parse/infer.c
@@ -1815,8 +1815,16 @@
     size_t i, j;
 
     t = tybase(tf(st, n->lit.type));
-    if (t->type != Tystruct)
-        fatal(n, "type %s for struct literal is not struct near %s", tystr(t), ctxstr(st, n));
+    if (t->type != Tystruct) {
+        /*
+         * If we haven't inferred the type, and it's inside another struct,
+         * we'll eventually get to it.
+         *
+         * If, on the other hand, it is genuinely underspecified, we'll give
+         * a better error on it later.
+         */
+        return;
+    }
 
     for (i = 0; i < n->expr.nargs; i++) {
         val = n->expr.args[i];