mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
Failed to reject void compile time variables, leading to crash. #2781
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
- Broken cast from fault to array pointer #2778.
|
||||
- $typeof untyped list crashes when trying to create typeid from it. #2779
|
||||
- Recursive constant definition not properly detected, leading to assert #2780
|
||||
- Failed to reject void compile time variables, leading to crash. #2781
|
||||
|
||||
### Fixes
|
||||
- Regression with npot vector in struct triggering an assert #2219.
|
||||
|
||||
@@ -4739,6 +4739,19 @@ bool sema_analyse_var_decl_ct(SemaContext *context, Decl *decl, bool *check_fail
|
||||
SEMA_ERROR(type_info, "No size could be inferred.");
|
||||
goto FAIL;
|
||||
}
|
||||
switch (sema_resolve_storage_type(context, decl->type))
|
||||
{
|
||||
case STORAGE_NORMAL:
|
||||
case STORAGE_COMPILE_TIME:
|
||||
break;
|
||||
case STORAGE_ERROR:
|
||||
goto FAIL;
|
||||
case STORAGE_VOID:
|
||||
case STORAGE_WILDCARD:
|
||||
case STORAGE_UNKNOWN:
|
||||
SEMA_ERROR(type_info, "Expected a runtime or compile time type with a well-defined zero value.");
|
||||
goto FAIL;
|
||||
}
|
||||
decl->var.init_expr = init = expr_new(EXPR_POISONED, decl->span);
|
||||
expr_rewrite_to_const_zero(init, type_no_optional(decl->type));
|
||||
}
|
||||
|
||||
9
test/test_suite/compile_time/ct_empty_var_void.c3
Normal file
9
test/test_suite/compile_time/ct_empty_var_void.c3
Normal file
@@ -0,0 +1,9 @@
|
||||
fn void a()
|
||||
{
|
||||
void? $y; // #error: Expected a runtime or compile time type with a well-defined zero value
|
||||
}
|
||||
fn int main()
|
||||
{
|
||||
void $x; // #error: Expected a runtime or compile time type with a well-defined zero value
|
||||
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
fn void a()
|
||||
{
|
||||
typeid a = $typeof({}); // #error: You cannot take the typeid of a compile time type
|
||||
var t @safeinfer = mem::new_array($typeof({}), 1); // #error: 'untyped_list' does not have a property or method 'alignof'
|
||||
}
|
||||
Reference in New Issue
Block a user