mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Error when using named argument on trailing macro body expansion #2139.
This commit is contained in:
@@ -31,6 +31,7 @@
|
|||||||
- Incorrect parsing of ad hoc generic types, like `Foo{int}****` #2140.
|
- Incorrect parsing of ad hoc generic types, like `Foo{int}****` #2140.
|
||||||
- $define did not correctly handle generic types #2140.
|
- $define did not correctly handle generic types #2140.
|
||||||
- Incorrect parsing of call attributes #2144.
|
- Incorrect parsing of call attributes #2144.
|
||||||
|
- Error when using named argument on trailing macro body expansion #2139.
|
||||||
|
|
||||||
### Stdlib changes
|
### Stdlib changes
|
||||||
- Added `String.quick_ztr` and `String.is_zstr`
|
- Added `String.quick_ztr` and `String.is_zstr`
|
||||||
|
|||||||
@@ -1290,6 +1290,11 @@ static bool sema_analyse_parameter(SemaContext *context, Expr *arg, Decl *param,
|
|||||||
{
|
{
|
||||||
case VARDECL_PARAM:
|
case VARDECL_PARAM:
|
||||||
// foo
|
// foo
|
||||||
|
if (arg->expr_kind == EXPR_NAMED_ARGUMENT)
|
||||||
|
{
|
||||||
|
// This only happens in body arguments
|
||||||
|
RETURN_SEMA_ERROR(arg, "Named arguments are not supported for body parameters.");
|
||||||
|
}
|
||||||
if (!sema_analyse_expr_rhs(context, type, arg, true, no_match_ref, false)) return false;
|
if (!sema_analyse_expr_rhs(context, type, arg, true, no_match_ref, false)) return false;
|
||||||
if (IS_OPTIONAL(arg)) *optional_ref = true;
|
if (IS_OPTIONAL(arg)) *optional_ref = true;
|
||||||
switch (sema_resolve_storage_type(context, arg->type))
|
switch (sema_resolve_storage_type(context, arg->type))
|
||||||
|
|||||||
9
test/test_suite/macros/trailing_body_named.c3
Normal file
9
test/test_suite/macros/trailing_body_named.c3
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
macro @foo(; @body(int arg))
|
||||||
|
{
|
||||||
|
@body(arg: 0); // #error: Named arguments are not supported for body parameters
|
||||||
|
}
|
||||||
|
|
||||||
|
fn void main()
|
||||||
|
{
|
||||||
|
@foo(; int arg) {};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user