From 3b38609a17725e680be3a3c6a922f9f19ee12ae6 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Sun, 2 May 2021 23:35:14 -0500 Subject: [PATCH] fixed anonymous struct var arg bug --- docs/bugs | 2 +- src/onyxchecker.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/bugs b/docs/bugs index 632a068f..e46bbf5d 100644 --- 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. diff --git a/src/onyxchecker.c b/src/onyxchecker.c index f9fa95dd..6ec36c90 100644 --- a/src/onyxchecker.c +++ b/src/onyxchecker.c @@ -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; } -- 2.25.1