aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp21
1 files changed, 6 insertions, 15 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp
index 14a4eebc8..3bd8bca07 100644
--- a/src/check_expr.cpp
+++ b/src/check_expr.cpp
@@ -7758,7 +7758,10 @@ gb_internal void add_constant_switch_case(CheckerContext *ctx, SeenMap *seen, Op
multi_map_get_all(seen, key, taps);
for (isize i = 0; i < count; i++) {
TypeAndToken tap = taps[i];
- if (!are_types_identical(operand.type, tap.type)) {
+ Operand to = {};
+ to.mode = Addressing_Value;
+ to.type = tap.type;
+ if (!check_is_assignable_to_with_score(ctx, &to, operand.type, nullptr)) {
continue;
}
@@ -7801,20 +7804,8 @@ gb_internal void add_to_seen_map(CheckerContext *ctx, SeenMap *seen, TokenKind u
break;
}
- bool found = false;
- for (Entity *f : bt->Enum.fields) {
- GB_ASSERT(f->kind == Entity_Constant);
-
- i64 fv = exact_value_to_i64(f->Constant.value);
- if (fv == vi) {
- found = true;
- break;
- }
- }
- if (found) {
- v.value = exact_value_i64(vi);
- add_constant_switch_case(ctx, seen, v);
- }
+ v.value = exact_value_i64(vi);
+ add_constant_switch_case(ctx, seen, v);
}
} else {
add_constant_switch_case(ctx, seen, lhs);