mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Non-const macros may not return untyped lists.
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
- Missing bounds check on upper bound with const ranges `foo[1:3]`.
|
||||
- Check up the hierarchy when considering if an interface cast is valid #2267.
|
||||
- Fix issue with labelled break inside of a $switch.
|
||||
- Non-const macros may not return untyped lists.
|
||||
|
||||
### Stdlib changes
|
||||
|
||||
|
||||
@@ -2859,11 +2859,14 @@ EXIT:
|
||||
}
|
||||
sema_context_destroy(¯o_context);
|
||||
call_expr->resolve_status = RESOLVE_DONE;
|
||||
if (is_always_const && !expr_is_runtime_const(call_expr))
|
||||
if (!expr_is_runtime_const(call_expr))
|
||||
{
|
||||
SEMA_ERROR(call_expr, "The macro failed to fold to a constant value, despite being '@const'.");
|
||||
SEMA_NOTE(decl, "The macro was declared here.");
|
||||
return false;
|
||||
if (is_always_const)
|
||||
{
|
||||
SEMA_ERROR(call_expr, "The macro failed to fold to a constant value, despite being '@const'.");
|
||||
SEMA_NOTE(decl, "The macro was declared here.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
EXIT_FAIL:
|
||||
|
||||
14
test/test_suite/compile_time/compile_time_untyped.c3
Normal file
14
test/test_suite/compile_time/compile_time_untyped.c3
Normal file
@@ -0,0 +1,14 @@
|
||||
struct Test
|
||||
{
|
||||
struct { int a; }
|
||||
}
|
||||
|
||||
macro test(int x)
|
||||
{
|
||||
return {{}};
|
||||
}
|
||||
fn int main()
|
||||
{
|
||||
Test a = test(3);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user