mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Issue where trailing body argument was allowed without type even though the definition specified it #1879.
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
- Correctly check jump table size and be generous when compiling it #1877.
|
||||
- Fix bug where .min/.max would fail on a distinct int #1888.
|
||||
- Fix issue where compile time declarations in expression list would not be handled properly.
|
||||
- Issue where trailing body argument was allowed without type even though the definition specified it #1879.
|
||||
|
||||
### Stdlib changes
|
||||
- Added '%h' and '%H' for printing out binary data in hexadecimal using the formatter.
|
||||
|
||||
@@ -2231,6 +2231,12 @@ bool sema_expr_analyse_macro_call(SemaContext *context, Expr *call_expr, Expr *s
|
||||
TypeInfo *type_info = vartype(body_arg);
|
||||
if (type_info && !sema_resolve_type_info(context, type_info, RESOLVE_TYPE_DEFAULT)) return false;
|
||||
Type *type = type_info ? type_info->type : NULL;
|
||||
if (!type && expected_type_info)
|
||||
{
|
||||
if (no_match_ref) goto NO_MATCH_REF;
|
||||
RETURN_SEMA_ERROR(body_arg, "This parameter should be explicitly typed to %s but was untyped.",
|
||||
type_quoted_error_string(expected_type_info->type));
|
||||
}
|
||||
if (type && expected_type_info && type->canonical != expected_type_info->type->canonical)
|
||||
{
|
||||
if (no_match_ref) goto NO_MATCH_REF;
|
||||
|
||||
17
test/test_suite/macros/macro_body_missing_type.c3
Normal file
17
test/test_suite/macros/macro_body_missing_type.c3
Normal file
@@ -0,0 +1,17 @@
|
||||
enum Foo
|
||||
{
|
||||
A,
|
||||
}
|
||||
|
||||
fn void main()
|
||||
{
|
||||
@test(;$f) // #error: should be explicitly
|
||||
{
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
macro @test(; @body(Foo $f))
|
||||
{
|
||||
@body(A);
|
||||
}
|
||||
Reference in New Issue
Block a user