diff --git a/lib/std/net/socket_private.c3 b/lib/std/net/socket_private.c3 index 2a8bfff03..87ca95faf 100644 --- a/lib/std/net/socket_private.c3 +++ b/lib/std/net/socket_private.c3 @@ -75,7 +75,7 @@ fn Socket? connect_with_timeout_from_addrinfo(AddrInfo* addrinfo, SocketOption[] { 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)!) { return CONNECTION_TIMED_OUT~; diff --git a/releasenotes.md b/releasenotes.md index f85beed82..766c19abb 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -41,6 +41,7 @@ - Improved underlining errors/warnings when unicode is used. #2887 - 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 +- On assert known false, the message was not show for no-args. ## 0.7.9 Change list diff --git a/src/compiler/sema_decls.c b/src/compiler/sema_decls.c index 0efd8e718..96085110f 100644 --- a/src/compiler/sema_decls.c +++ b/src/compiler/sema_decls.c @@ -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_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) { 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. */ -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; 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 (!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); 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 (check_failed) goto FAIL_CHECK; + if (check_defined) goto FAIL_CHECK; SEMA_ERROR(type_info, "No size could be inferred."); goto FAIL; } @@ -4762,7 +4760,7 @@ bool sema_analyse_var_decl_ct(SemaContext *context, Decl *decl, bool *check_fail // Check that it is constant. 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); 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 (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); goto FAIL; } @@ -4781,7 +4779,7 @@ bool sema_analyse_var_decl_ct(SemaContext *context, Decl *decl, bool *check_fail // Check it is constant. 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); goto FAIL; } @@ -4795,12 +4793,12 @@ bool sema_analyse_var_decl_ct(SemaContext *context, Decl *decl, bool *check_fail default: UNREACHABLE } - if (check_failed) return true; + if (check_defined) return true; return sema_add_local(context, decl); FAIL_CHECK: - if (check_failed) + if (check_defined) { - *check_failed = true; + *check_defined = true; return false; } FAIL: diff --git a/src/compiler/sema_stmts.c b/src/compiler/sema_stmts.c index 67a6514f0..b47e8a843 100644 --- a/src/compiler/sema_stmts.c +++ b/src/compiler/sema_stmts.c @@ -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 (!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) { 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; 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. 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)); }