mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Correctly poison the analysis after a failed $assert or $error. #2284
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
- Fix to codegen when using a bitstruct constant defined using a cast with an operator #2248.
|
||||
- Function pointers are now compile time constants.
|
||||
- Splat 8 arguments can sometimes cause incorrect behaviour in the compiler. #2283
|
||||
- Correctly poison the analysis after a failed $assert or $error. #2284
|
||||
|
||||
### Stdlib changes
|
||||
- Improve contract for readline. #2280
|
||||
|
||||
@@ -2930,7 +2930,7 @@ bool sema_analyse_ct_assert_stmt(SemaContext *context, Ast *statement)
|
||||
if (!sema_analyse_expr(context, message_expr)) return false;
|
||||
if (message_expr->expr_kind != EXPR_CONST || message_expr->const_expr.const_kind != CONST_STRING)
|
||||
{
|
||||
SEMA_ERROR(message_expr, "Expected a string as the error message.");
|
||||
RETURN_SEMA_ERROR(message_expr, "Expected a string as the error message.");
|
||||
}
|
||||
}
|
||||
CondResult res = expr ? sema_check_comp_time_bool(context, expr) : COND_FALSE;
|
||||
@@ -2949,6 +2949,7 @@ bool sema_analyse_ct_assert_stmt(SemaContext *context, Ast *statement)
|
||||
{
|
||||
sema_error_at(context, span, "Compile time assert failed.");
|
||||
}
|
||||
context->active_scope.is_poisoned = true;
|
||||
return false;
|
||||
}
|
||||
statement->ast_kind = AST_NOP_STMT;
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
fn void main()
|
||||
{
|
||||
$error "Foo %s", 1; // #error: Foo 1
|
||||
$assert 0 > 1 : "Foo %s", 0.0002;
|
||||
}
|
||||
|
||||
fn void test()
|
||||
{
|
||||
$assert 0 > 1 : "Foo %s", 0.0002; // #error: Foo 0.0002
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user