From 3c25d93eae4e5aac76c09d7018cf8a440eab700b Mon Sep 17 00:00:00 2001 From: jakubtomsu <66876057+jakubtomsu@users.noreply.github.com> Date: Sat, 25 Nov 2023 13:20:34 +0100 Subject: [PATCH 1/2] Check for variadic param default val --- src/check_type.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/check_type.cpp b/src/check_type.cpp index d66b196bc..33881aa8f 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -1510,8 +1510,10 @@ gb_internal Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_para } if (default_value != nullptr) { - if (type_expr != nullptr && type_expr->kind == Ast_TypeidType) { + if (type_expr->kind == Ast_TypeidType) { error(type_expr, "A type parameter may not have a default value"); + } else if (is_variadic) { + error(type_expr, "A variadic parameter may not have a default value"); } else { param_value = handle_parameter_value(ctx, type, nullptr, default_value, true); } From fe268a9dd29a85d7b7a021cd5a0659a8b8300172 Mon Sep 17 00:00:00 2001 From: jakubtomsu <66876057+jakubtomsu@users.noreply.github.com> Date: Sat, 25 Nov 2023 13:29:28 +0100 Subject: [PATCH 2/2] Add nullptr check back --- src/check_type.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/check_type.cpp b/src/check_type.cpp index 33881aa8f..343f0b7bc 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -1510,7 +1510,7 @@ gb_internal Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_para } if (default_value != nullptr) { - if (type_expr->kind == Ast_TypeidType) { + if (type_expr != nullptr && type_expr->kind == Ast_TypeidType) { error(type_expr, "A type parameter may not have a default value"); } else if (is_variadic) { error(type_expr, "A variadic parameter may not have a default value");