Do not do certain implicit conversions on enums in binary expression.

This commit is contained in:
Christoffer Lerno
2025-07-06 21:44:06 +02:00
parent e15fdc709f
commit 19acdc7a19
2 changed files with 31 additions and 1 deletions

View File

@@ -1969,7 +1969,6 @@ RETRY_DISTINCT:
return NULL;
case ALL_INTS:
if (type_is_distinct_like(other) && type_underlying_is_numeric(other)) return other;
if (other->type_kind == TYPE_ENUM) return type_find_max_type(type, enum_inner_type(other)->canonical);
if (other->type_kind == TYPE_VECTOR) return other;
return type_find_max_num_type(type, other);
case ALL_FLOATS:

View File

@@ -0,0 +1,31 @@
// #target: macos-x64
module test;
enum Foo : inline uint
{
BAR,
ABC,
DEF
}
const BAZ = (1U << Foo.BAR);
fn int main()
{
var $var = 1U << Foo.ABC;
var $var2 = 1U << Foo.DEF;
int a = $var;
int b = $var2;
return 0;
}
/* #expect: test.ll
define i32 @main() #0 {
entry:
%a = alloca i32, align 4
%b = alloca i32, align 4
store i32 2, ptr %a, align 4
store i32 4, ptr %b, align 4
ret i32 0
}