Missing error on default values for body with default arguments #2148.

This commit is contained in:
Christoffer Lerno
2025-05-23 18:57:21 +02:00
parent 6c0e94cad9
commit 9d5b31dad5
3 changed files with 19 additions and 0 deletions

View File

@@ -36,6 +36,7 @@
- Designated const initializers with `{}` would overwrite the parent field. - Designated const initializers with `{}` would overwrite the parent field.
- Empty default case in @jump switch does not fallthrough #2147. - Empty default case in @jump switch does not fallthrough #2147.
- `&&&` was accidentally available as a valid prefix operator. - `&&&` was accidentally available as a valid prefix operator.
- Missing error on default values for body with default arguments #2148.
### Stdlib changes ### Stdlib changes
- Added `String.quick_ztr` and `String.is_zstr` - Added `String.quick_ztr` and `String.is_zstr`

View File

@@ -4094,6 +4094,10 @@ INLINE bool sema_analyse_macro_body(SemaContext *context, Decl **body_parameters
ASSERT(param->decl_kind == DECL_VAR); ASSERT(param->decl_kind == DECL_VAR);
TypeInfo *type_info = type_infoptrzero(param->var.type_info); TypeInfo *type_info = type_infoptrzero(param->var.type_info);
VarDeclKind kind = param->var.kind; VarDeclKind kind = param->var.kind;
if (param->var.init_expr)
{
RETURN_SEMA_ERROR(param->var.init_expr, "Body parameters cannot use default values.");
}
switch (kind) switch (kind)
{ {
case VARDECL_PARAM: case VARDECL_PARAM:

View File

@@ -0,0 +1,14 @@
import std;
fn void main()
{
@foo(;int x)
{
io::printn(x);
};
}
macro @foo(; @body(int x = 1)) // #error: Body parameters
{
@body(3);
}