mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Fix add_constant_switch_case
This commit is contained in:
+6
-15
@@ -7758,7 +7758,10 @@ gb_internal void add_constant_switch_case(CheckerContext *ctx, SeenMap *seen, Op
|
|||||||
multi_map_get_all(seen, key, taps);
|
multi_map_get_all(seen, key, taps);
|
||||||
for (isize i = 0; i < count; i++) {
|
for (isize i = 0; i < count; i++) {
|
||||||
TypeAndToken tap = taps[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;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7801,20 +7804,8 @@ gb_internal void add_to_seen_map(CheckerContext *ctx, SeenMap *seen, TokenKind u
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool found = false;
|
v.value = exact_value_i64(vi);
|
||||||
for (Entity *f : bt->Enum.fields) {
|
add_constant_switch_case(ctx, seen, v);
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
add_constant_switch_case(ctx, seen, lhs);
|
add_constant_switch_case(ctx, seen, lhs);
|
||||||
|
|||||||
Reference in New Issue
Block a user