aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2026-01-11 18:54:55 +0000
committergingerBill <gingerBill@users.noreply.github.com>2026-01-11 18:54:55 +0000
commit0f875727a2a13b13f2afb4404cf6d2a4d8921af0 (patch)
tree2f523bb7670a1f760d67ce37b6179b24a334c416 /src/check_expr.cpp
parent5938c783a69e826cd8c113521a3950a6bacdb9aa (diff)
parent3345ed0622954abc1bb5a781445c152735661bb6 (diff)
Merge branch 'master' of https://github.com/odin-lang/Odin
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp23
1 files changed, 6 insertions, 17 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index c4f235b51..cd2307c6d 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -3526,28 +3526,17 @@ gb_internal bool check_cast_internal(CheckerContext *c, Operand *x, Type *type)
Type *elem = core_array_type(bt);
if (core_type(bt)->kind == Type_Basic) {
- if (check_representable_as_constant(c, x->value, type, &x->value)) {
- return true;
- }
- goto check_castable;
- } else if (!are_types_identical(elem, bt) &&
- elem->kind == Type_Basic &&
- check_representable_as_constant(c, x->value, elem, &x->value)) {
- if (check_representable_as_constant(c, x->value, type, &x->value)) {
- return true;
- }
- goto check_castable;
+ return check_representable_as_constant(c, x->value, type, &x->value) ||
+ (is_type_pointer(type) && check_is_castable_to(c, x, type));
+ } else if (!are_types_identical(elem, bt) && elem->kind == Type_Basic && x->type->kind == Type_Basic) {
+ return check_representable_as_constant(c, x->value, elem, &x->value) ||
+ (is_type_pointer(elem) && check_is_castable_to(c, x, elem));
} else if (check_is_castable_to(c, x, type)) {
x->value = {};
x->mode = Addressing_Value;
return true;
}
-
- return false;
- }
-
-check_castable:
- if (check_is_castable_to(c, x, type)) {
+ } else if (check_is_castable_to(c, x, type)) {
if (x->mode != Addressing_Constant) {
x->mode = Addressing_Value;
} else if (is_type_slice(type) && is_type_string(x->type)) {