fixed anonymous struct var arg bug
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 3 May 2021 04:35:14 +0000 (23:35 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 3 May 2021 04:35:14 +0000 (23:35 -0500)
docs/bugs
src/onyxchecker.c

index 632a068fbd5dec1876f26f12d9d61dd7b98ab07b..e46bbf5d793d1f089c63b5e7acbec19c2358bd99 100644 (file)
--- a/docs/bugs
+++ b/docs/bugs
@@ -36,7 +36,7 @@ List of known bugs:
         SN.foo()
     }
 
-[ ] There is a segfault when passing an anonymous struct literal to an untyped vararg.
+[X] There is a segfault when passing an anonymous struct literal to an untyped vararg.
     Should just need to detect this case and provide an error message since this doesn't
     make any sense semantically.
     
index f9fa95dd44fc13edc4e7e47035ab003118a1be50..6ec36c90fa3fa4ec109991b81604822fe6b1ba98 100644 (file)
@@ -530,6 +530,11 @@ CheckStatus check_call(AstCall* call) {
                 if (arg_pos >= (u32) bh_arr_length(arg_arr)) goto type_checking_done;
 
                 resolve_expression_type(arg_arr[arg_pos]->value);
+                if (arg_arr[arg_pos]->value->type == NULL) {
+                    onyx_report_error(arg_arr[arg_pos]->token->pos, "Unable to resolve type for argument.");
+                    return Check_Error;
+                }
+
                 arg_arr[arg_pos]->va_kind = VA_Kind_Untyped;
                 break;
             }