mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
- On assert known false, the message was not show for no-args.
- Fixup in socket_private.c3
This commit is contained in:
@@ -75,7 +75,7 @@ fn Socket? connect_with_timeout_from_addrinfo(AddrInfo* addrinfo, SocketOption[]
|
|||||||
{
|
{
|
||||||
c = clock::now();
|
c = clock::now();
|
||||||
}
|
}
|
||||||
Poll poll_request = { sockfd, SUBSCRIBE_ANY_WRITE, 0 };
|
Poll poll_request = { sockfd, SUBSCRIBE_ANY_WRITE, (PollEvent)0 };
|
||||||
if (!poll((&poll_request)[:1], timeout_left)!)
|
if (!poll((&poll_request)[:1], timeout_left)!)
|
||||||
{
|
{
|
||||||
return CONNECTION_TIMED_OUT~;
|
return CONNECTION_TIMED_OUT~;
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
- Improved underlining errors/warnings when unicode is used. #2887
|
- Improved underlining errors/warnings when unicode is used. #2887
|
||||||
- Fix std::io::Formatter integer issue for large uint128 decimal values.
|
- Fix std::io::Formatter integer issue for large uint128 decimal values.
|
||||||
- `--safe=no` disabled compile-time errors on compile-time known runtime @require checks #2936
|
- `--safe=no` disabled compile-time errors on compile-time known runtime @require checks #2936
|
||||||
|
- On assert known false, the message was not show for no-args.
|
||||||
|
|
||||||
## 0.7.9 Change list
|
## 0.7.9 Change list
|
||||||
|
|
||||||
|
|||||||
@@ -46,8 +46,6 @@ static bool sema_analyse_variable_type(SemaContext *context, Type *type, SourceS
|
|||||||
static inline bool sema_analyse_alias(SemaContext *context, Decl *decl, bool *erase_decl);
|
static inline bool sema_analyse_alias(SemaContext *context, Decl *decl, bool *erase_decl);
|
||||||
static inline bool sema_analyse_typedef(SemaContext *context, Decl *decl, bool *erase_decl);
|
static inline bool sema_analyse_typedef(SemaContext *context, Decl *decl, bool *erase_decl);
|
||||||
|
|
||||||
static CompilationUnit *unit_copy_for_generic(Module *module, CompilationUnit *unit);
|
|
||||||
|
|
||||||
static inline bool sema_resolve_align_expr(SemaContext *context, Expr *expr, AlignSize *result)
|
static inline bool sema_resolve_align_expr(SemaContext *context, Expr *expr, AlignSize *result)
|
||||||
{
|
{
|
||||||
if (!sema_analyse_expr_rvalue(context, expr)) return false;
|
if (!sema_analyse_expr_rvalue(context, expr)) return false;
|
||||||
@@ -4681,7 +4679,7 @@ static bool sema_analyse_variable_type(SemaContext *context, Type *type, SourceS
|
|||||||
/**
|
/**
|
||||||
* Analyse $foo and $Foo variables.
|
* Analyse $foo and $Foo variables.
|
||||||
*/
|
*/
|
||||||
bool sema_analyse_var_decl_ct(SemaContext *context, Decl *decl, bool *check_failed)
|
bool sema_analyse_var_decl_ct(SemaContext *context, Decl *decl, bool *check_defined)
|
||||||
{
|
{
|
||||||
Expr *init;
|
Expr *init;
|
||||||
ASSERT(decl->decl_kind == DECL_VAR && "Should only be called on variables.");
|
ASSERT(decl->decl_kind == DECL_VAR && "Should only be called on variables.");
|
||||||
@@ -4711,7 +4709,7 @@ bool sema_analyse_var_decl_ct(SemaContext *context, Decl *decl, bool *check_fail
|
|||||||
// If this isn't a type, it's an error.
|
// If this isn't a type, it's an error.
|
||||||
if (!expr_is_const_typeid(init))
|
if (!expr_is_const_typeid(init))
|
||||||
{
|
{
|
||||||
if (check_failed) goto FAIL_CHECK;
|
if (check_defined) goto FAIL_CHECK;
|
||||||
SEMA_ERROR(decl->var.init_expr, "Expected a type assigned to %s.", decl->name);
|
SEMA_ERROR(decl->var.init_expr, "Expected a type assigned to %s.", decl->name);
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
}
|
}
|
||||||
@@ -4731,7 +4729,7 @@ bool sema_analyse_var_decl_ct(SemaContext *context, Decl *decl, bool *check_fail
|
|||||||
{
|
{
|
||||||
if (type_is_inferred(decl->type))
|
if (type_is_inferred(decl->type))
|
||||||
{
|
{
|
||||||
if (check_failed) goto FAIL_CHECK;
|
if (check_defined) goto FAIL_CHECK;
|
||||||
SEMA_ERROR(type_info, "No size could be inferred.");
|
SEMA_ERROR(type_info, "No size could be inferred.");
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
}
|
}
|
||||||
@@ -4762,7 +4760,7 @@ bool sema_analyse_var_decl_ct(SemaContext *context, Decl *decl, bool *check_fail
|
|||||||
// Check that it is constant.
|
// Check that it is constant.
|
||||||
if (!expr_is_runtime_const(init))
|
if (!expr_is_runtime_const(init))
|
||||||
{
|
{
|
||||||
if (check_failed) goto FAIL_CHECK;
|
if (check_defined) goto FAIL_CHECK;
|
||||||
SEMA_ERROR(init, "Expected a constant expression assigned to %s.", decl->name);
|
SEMA_ERROR(init, "Expected a constant expression assigned to %s.", decl->name);
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
}
|
}
|
||||||
@@ -4773,7 +4771,7 @@ bool sema_analyse_var_decl_ct(SemaContext *context, Decl *decl, bool *check_fail
|
|||||||
{
|
{
|
||||||
if (init->expr_kind == EXPR_TYPEINFO)
|
if (init->expr_kind == EXPR_TYPEINFO)
|
||||||
{
|
{
|
||||||
if (check_failed) goto FAIL_CHECK;
|
if (check_defined) goto FAIL_CHECK;
|
||||||
SEMA_ERROR(init, "You can't assign a type to a regular compile time variable like '%s', but it would be allowed if the variable was a compile time type variable. Such a variable needs to have a type-like name, e.g. '$MyType'.", decl->name);
|
SEMA_ERROR(init, "You can't assign a type to a regular compile time variable like '%s', but it would be allowed if the variable was a compile time type variable. Such a variable needs to have a type-like name, e.g. '$MyType'.", decl->name);
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
}
|
}
|
||||||
@@ -4781,7 +4779,7 @@ bool sema_analyse_var_decl_ct(SemaContext *context, Decl *decl, bool *check_fail
|
|||||||
// Check it is constant.
|
// Check it is constant.
|
||||||
if (!expr_is_runtime_const(init))
|
if (!expr_is_runtime_const(init))
|
||||||
{
|
{
|
||||||
if (check_failed) goto FAIL_CHECK;
|
if (check_defined) goto FAIL_CHECK;
|
||||||
SEMA_ERROR(init, "Expected a constant expression assigned to %s.", decl->name);
|
SEMA_ERROR(init, "Expected a constant expression assigned to %s.", decl->name);
|
||||||
goto FAIL;
|
goto FAIL;
|
||||||
}
|
}
|
||||||
@@ -4795,12 +4793,12 @@ bool sema_analyse_var_decl_ct(SemaContext *context, Decl *decl, bool *check_fail
|
|||||||
default:
|
default:
|
||||||
UNREACHABLE
|
UNREACHABLE
|
||||||
}
|
}
|
||||||
if (check_failed) return true;
|
if (check_defined) return true;
|
||||||
return sema_add_local(context, decl);
|
return sema_add_local(context, decl);
|
||||||
FAIL_CHECK:
|
FAIL_CHECK:
|
||||||
if (check_failed)
|
if (check_defined)
|
||||||
{
|
{
|
||||||
*check_failed = true;
|
*check_defined = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
FAIL:
|
FAIL:
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ static inline bool sema_analyse_assert_stmt(SemaContext *context, Ast *statement
|
|||||||
{
|
{
|
||||||
if (!sema_analyse_ct_expr(context, message_expr)) return false;
|
if (!sema_analyse_ct_expr(context, message_expr)) return false;
|
||||||
if (!expr_is_const_string(message_expr)) RETURN_SEMA_ERROR(message_expr, "Expected a constant string as the error message.");
|
if (!expr_is_const_string(message_expr)) RETURN_SEMA_ERROR(message_expr, "Expected a constant string as the error message.");
|
||||||
|
|
||||||
FOREACH(Expr *, e, statement->assert_stmt.args)
|
FOREACH(Expr *, e, statement->assert_stmt.args)
|
||||||
{
|
{
|
||||||
if (!sema_analyse_expr_rvalue(context, e)) return false;
|
if (!sema_analyse_expr_rvalue(context, e)) return false;
|
||||||
@@ -137,6 +138,7 @@ static inline bool sema_analyse_assert_stmt(SemaContext *context, Ast *statement
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We might have `assert(false)` or `assert(true)`
|
||||||
CondResult result_no_resolve = COND_MISSING;
|
CondResult result_no_resolve = COND_MISSING;
|
||||||
if (expr->resolve_status == RESOLVE_DONE && expr_is_const_bool(expr))
|
if (expr->resolve_status == RESOLVE_DONE && expr_is_const_bool(expr))
|
||||||
{
|
{
|
||||||
@@ -170,7 +172,7 @@ static inline bool sema_analyse_assert_stmt(SemaContext *context, Ast *statement
|
|||||||
// Otherwise we print an error.
|
// Otherwise we print an error.
|
||||||
if (!context->active_scope.end_jump.active && !context->active_scope.is_dead)
|
if (!context->active_scope.end_jump.active && !context->active_scope.is_dead)
|
||||||
{
|
{
|
||||||
if (message_expr && sema_cast_const(message_expr) && vec_size(statement->assert_stmt.args))
|
if (message_expr && sema_cast_const(message_expr) && !vec_size(statement->assert_stmt.args))
|
||||||
{
|
{
|
||||||
RETURN_SEMA_ERROR(expr, "%.*s", EXPAND_EXPR_STRING(message_expr));
|
RETURN_SEMA_ERROR(expr, "%.*s", EXPAND_EXPR_STRING(message_expr));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user