mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Missing error on default values for body with default arguments #2148.
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
- Designated const initializers with `{}` would overwrite the parent field.
|
||||
- Empty default case in @jump switch does not fallthrough #2147.
|
||||
- `&&&` was accidentally available as a valid prefix operator.
|
||||
- Missing error on default values for body with default arguments #2148.
|
||||
|
||||
### Stdlib changes
|
||||
- Added `String.quick_ztr` and `String.is_zstr`
|
||||
|
||||
@@ -4094,6 +4094,10 @@ INLINE bool sema_analyse_macro_body(SemaContext *context, Decl **body_parameters
|
||||
ASSERT(param->decl_kind == DECL_VAR);
|
||||
TypeInfo *type_info = type_infoptrzero(param->var.type_info);
|
||||
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)
|
||||
{
|
||||
case VARDECL_PARAM:
|
||||
|
||||
14
test/test_suite/macros/macro_body_error_2148.c3
Normal file
14
test/test_suite/macros/macro_body_error_2148.c3
Normal 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);
|
||||
}
|
||||
Reference in New Issue
Block a user