Fix regression: Enum inference with compare operators #2241

This commit is contained in:
Christoffer Lerno
2025-06-25 00:55:29 +02:00
parent faf073885f
commit 2b0fb52f65
3 changed files with 14 additions and 1 deletions

View File

@@ -3328,6 +3328,7 @@ static inline LLVMValueRef llvm_emit_mult_int(GenContext *c, Type *type, LLVMVal
static void llvm_emit_slice_comp(GenContext *c, BEValue *be_value, BEValue *lhs, BEValue *rhs, BinaryOp binary_op) static void llvm_emit_slice_comp(GenContext *c, BEValue *be_value, BEValue *lhs, BEValue *rhs, BinaryOp binary_op)
{ {
bool want_match = binary_op == BINARYOP_EQ; bool want_match = binary_op == BINARYOP_EQ;
Type *array_base_type = type_lowering(lhs->type->array.base); Type *array_base_type = type_lowering(lhs->type->array.base);

View File

@@ -1227,7 +1227,8 @@ static inline bool sema_binary_analyse_with_inference(SemaContext *context, Expr
{ {
const static int op_table[BINARYOP_LAST + 1] = { const static int op_table[BINARYOP_LAST + 1] = {
[BINARYOP_AND] = 1, [BINARYOP_OR] = 1, [BINARYOP_CT_AND] = 1, [BINARYOP_CT_OR] = 1, [BINARYOP_AND] = 1, [BINARYOP_OR] = 1, [BINARYOP_CT_AND] = 1, [BINARYOP_CT_OR] = 1,
[BINARYOP_EQ] = 2, [BINARYOP_NE] = 2 }; [BINARYOP_EQ] = 2, [BINARYOP_NE] = 2, [BINARYOP_GT] = 2, [BINARYOP_GE] = 2,
[BINARYOP_LE] = 2, [BINARYOP_LT] = 2 };
int op_result = op_table[op]; int op_result = op_table[op];
if (op_result == 1) return true; if (op_result == 1) return true;
// If lhs or rhs is an initializer list, infer // If lhs or rhs is an initializer list, infer

View File

@@ -0,0 +1,11 @@
import std;
enum Foo
{
A, B, C
}
fn int main()
{
assert(Foo.A < B);
return 0;
}