mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Fix regression: Enum inference with compare operators #2241
This commit is contained in:
@@ -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);
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
11
test/test_suite/enumerations/enum_compare_inference.c3
Normal file
11
test/test_suite/enumerations/enum_compare_inference.c3
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import std;
|
||||||
|
enum Foo
|
||||||
|
{
|
||||||
|
A, B, C
|
||||||
|
}
|
||||||
|
|
||||||
|
fn int main()
|
||||||
|
{
|
||||||
|
assert(Foo.A < B);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user