diff options
| author | Laytan <laytanlaats@hotmail.com> | 2024-08-21 15:11:16 +0200 |
|---|---|---|
| committer | Laytan <laytanlaats@hotmail.com> | 2024-08-21 15:11:16 +0200 |
| commit | 63cd9a031a76220dc31ef8c009b47ace9fc2b0fd (patch) | |
| tree | 98134b02dbaeeed596197cdf49b93d7eb2dd4e45 /src/check_type.cpp | |
| parent | c77e8ca4014d704190773d2254c618b089d612a7 (diff) | |
fix variadic parameter with default value error check
Diffstat (limited to 'src/check_type.cpp')
| -rw-r--r-- | src/check_type.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/check_type.cpp b/src/check_type.cpp index 83b6600c8..3767f7666 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -1781,6 +1781,11 @@ gb_internal Type *check_get_params(CheckerContext *ctx, Scope *scope, Ast *_para success = false; } + if (default_value != nullptr) { + error(type_expr, "A variadic parameter may not have a default value"); + success = false; + } + GB_ASSERT(original_type_expr->kind == Ast_Ellipsis); type_expr = ast_array_type(type_expr->file(), original_type_expr->Ellipsis.token, nullptr, type_expr); } @@ -1819,8 +1824,6 @@ 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) { 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); } |