diff --git a/src/compiler/sema_casts.c b/src/compiler/sema_casts.c index fee43fe17..c4d3c649b 100644 --- a/src/compiler/sema_casts.c +++ b/src/compiler/sema_casts.c @@ -1898,14 +1898,14 @@ void cast_to_max_bit_size(SemaContext *context, Expr *left, Expr *right, Type *l Type *to = left->type->type_kind < TYPE_U8 ? type_int_signed_by_bitsize(bit_size_right) : type_int_unsigned_by_bitsize(bit_size_right); - bool success = cast_implicit(context, left, to); + bool success = cast(left, to); assert(success); return; } Type *to = right->type->type_kind < TYPE_U8 ? type_int_signed_by_bitsize(bit_size_left) : type_int_unsigned_by_bitsize(bit_size_left); - bool success = cast_implicit(context, right, to); + bool success = cast(right, to); assert(success); } diff --git a/src/compiler/sema_expr.c b/src/compiler/sema_expr.c index 23867741e..df5a5a536 100644 --- a/src/compiler/sema_expr.c +++ b/src/compiler/sema_expr.c @@ -4083,16 +4083,17 @@ static bool sema_expr_analyse_op_assign(SemaContext *context, Expr *expr, Expr * if (!sema_expr_check_assign(context, left)) return false; Type *no_fail = type_no_optional(left->type); + Type *flat = type_flatten_distinct(no_fail); // 3. If this is only defined for ints (*%, ^= |= &= %=) verify that this is an int. - if (int_only && !type_is_integer(no_fail)) + if (int_only && !type_is_integer(flat)) { SEMA_ERROR(left, "Expected an integer here."); return false; } // 4. In any case, these ops are only defined on numbers. - if (!type_underlying_is_numeric(no_fail)) + if (!type_underlying_is_numeric(flat)) { SEMA_ERROR(left, "Expected a numeric type here."); return false; @@ -5005,7 +5006,10 @@ static bool sema_expr_analyse_comp(SemaContext *context, Expr *expr, Expr *left, } // 6. Do the implicit cast. - bool success = cast_implicit(context, left, max) && cast_implicit(context, right, max); + bool success = true; + if (!cast_implicit(context, left, max)) success = cast(left, max); + if (!cast_implicit(context, right, max)) success = success && cast(right, max); + assert(success); DONE: diff --git a/src/compiler/sema_stmts.c b/src/compiler/sema_stmts.c index 975ac1688..55314e81f 100644 --- a/src/compiler/sema_stmts.c +++ b/src/compiler/sema_stmts.c @@ -1538,6 +1538,7 @@ static inline bool sema_analyse_if_stmt(SemaContext *context, Ast *statement) SCOPE_END; } + if (!success) goto END; else_jump = false; if (statement->if_stmt.else_body) { @@ -1549,9 +1550,11 @@ static inline bool sema_analyse_if_stmt(SemaContext *context, Ast *statement) SCOPE_END; } +END: context_pop_defers_and_replace_ast(context, statement); SCOPE_OUTER_END; + if (!success) return false; if (then_jump) { sema_unwrappable_from_catch_in_else(context, cond); @@ -1560,7 +1563,7 @@ static inline bool sema_analyse_if_stmt(SemaContext *context, Ast *statement) { context->active_scope.jump_end = true; } - return success; + return true; } static bool sema_analyse_asm_string_stmt(SemaContext *context, Ast *stmt) diff --git a/src/version.h b/src/version.h index 2a2d89181..1ed2a0f87 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define COMPILER_VERSION "0.3.121" \ No newline at end of file +#define COMPILER_VERSION "0.3.122" \ No newline at end of file