diff options
| author | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2025-12-10 16:12:54 +0100 |
|---|---|---|
| committer | Jeroen van Rijn <Kelimion@users.noreply.github.com> | 2025-12-10 16:12:54 +0100 |
| commit | 503269b9bf896d4263c90e76ce65dbfc1fadb27e (patch) | |
| tree | 1a6e16aaff123fdc99b15ab8d00a9405fa01830c /src | |
| parent | 72d65603eb513d6788a21f02bc211b662c6102e8 (diff) | |
| parent | 8610acb48f2fd0c9d280c9a7973caf8db4143cf9 (diff) | |
Merge branch 'master' into pr/5882
Diffstat (limited to 'src')
| -rw-r--r-- | src/check_expr.cpp | 8 | ||||
| -rw-r--r-- | src/llvm_backend_expr.cpp | 4 | ||||
| -rw-r--r-- | src/types.cpp | 3 |
3 files changed, 8 insertions, 7 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 418fb5378..470290d49 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -2116,9 +2116,6 @@ gb_internal bool check_representable_as_constant(CheckerContext *c, ExactValue i } return in_value.kind == ExactValue_String; } else if (is_type_integer(type) || is_type_rune(type)) { - if (in_value.kind == ExactValue_Bool) { - return false; - } ExactValue v = exact_value_to_integer(in_value); if (v.kind != ExactValue_Integer) { return false; @@ -4172,7 +4169,7 @@ gb_internal void check_binary_expr(CheckerContext *c, Operand *x, Ast *node, Typ default: if (is_ise_expr(be->left)) { // Evalute the right before the left for an '.X' expression - check_expr_or_type(c, y, be->right, type_hint); + check_expr_or_type(c, y, be->right, token_is_comparison(op.kind) ? nullptr : type_hint); if (can_use_other_type_as_type_hint(use_lhs_as_type_hint, y->type)) { // RHS in this case check_expr_or_type(c, x, be->left, y->type); @@ -4184,7 +4181,7 @@ gb_internal void check_binary_expr(CheckerContext *c, Operand *x, Ast *node, Typ if (can_use_other_type_as_type_hint(use_lhs_as_type_hint, x->type)) { check_expr_with_type_hint(c, y, be->right, x->type); } else { - check_expr_with_type_hint(c, y, be->right, type_hint); + check_expr_with_type_hint(c, y, be->right, token_is_comparison(op.kind) ? nullptr : type_hint); } } break; @@ -8148,6 +8145,7 @@ gb_internal ExprKind check_call_expr_as_type_cast(CheckerContext *c, Operand *op if (operand->mode != Addressing_Invalid) { update_untyped_expr_type(c, arg, t, false); + check_representable_as_constant(c, operand->value, t, &operand->value); } break; } diff --git a/src/llvm_backend_expr.cpp b/src/llvm_backend_expr.cpp index 9b8df5a37..dba61df44 100644 --- a/src/llvm_backend_expr.cpp +++ b/src/llvm_backend_expr.cpp @@ -5785,11 +5785,11 @@ gb_internal lbAddr lb_build_addr_internal(lbProcedure *p, Ast *expr) { if (is_type_union(t)) { Type *type = type_of_expr(expr); lbAddr v = lb_add_local_generated(p, type, false); - lb_addr_store(p, v, lb_emit_union_cast(p, lb_build_expr(p, ta->expr), type, pos)); + lb_addr_store(p, v, lb_emit_union_cast(p, e, type, pos)); return v; } else if (is_type_any(t)) { Type *type = type_of_expr(expr); - return lb_emit_any_cast_addr(p, lb_build_expr(p, ta->expr), type, pos); + return lb_emit_any_cast_addr(p, e, type, pos); } else { GB_PANIC("TODO(bill): type assertion %s", type_to_string(e.type)); } diff --git a/src/types.cpp b/src/types.cpp index eb20b8edf..18e3b56ac 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -4278,6 +4278,9 @@ gb_internal i64 *type_set_offsets_of(Slice<Entity *> const &fields, bool is_pack gb_internal bool type_set_offsets(Type *t) { t = base_type(t); if (t->kind == Type_Struct) { + if (t->Struct.are_offsets_being_processed.load()) { + return true; + } MUTEX_GUARD(&t->Struct.offset_mutex); if (!t->Struct.are_offsets_set) { t->Struct.are_offsets_being_processed.store(true); |