diff --git a/compiler/constants.jou b/compiler/constants.jou index 150592d8..a8a2d185 100644 --- a/compiler/constants.jou +++ b/compiler/constants.jou @@ -64,7 +64,6 @@ class Constant: case ConstantKind.String: printf("string ") print_string(self->str, strlen(self->str)) - printf("\n") def free(self) -> None: if self->kind == ConstantKind.String: diff --git a/compiler/typecheck/step3_function_and_method_bodies.jou b/compiler/typecheck/step3_function_and_method_bodies.jou index 595ea962..38a18428 100644 --- a/compiler/typecheck/step3_function_and_method_bodies.jou +++ b/compiler/typecheck/step3_function_and_method_bodies.jou @@ -378,7 +378,7 @@ def check_binop( got_bools = lhs->types.type == boolType and rhs->types.type == boolType got_integers = lhs->types.type->is_integer_type() and rhs->types.type->is_integer_type() got_numbers = lhs->types.type->is_number_type() and rhs->types.type->is_number_type() - got_enums = lhs->types.type->kind == TypeKind.Enum and rhs->types.type->kind == TypeKind.Enum + got_enums = lhs->types.type->kind == TypeKind.Enum and lhs->types.type == rhs->types.type got_pointers = ( lhs->types.type->is_pointer_type() and rhs->types.type->is_pointer_type() diff --git a/tests/wrong_type/enums_mix_eq.jou b/tests/wrong_type/enums_mix_eq.jou new file mode 100644 index 00000000..a61de20f --- /dev/null +++ b/tests/wrong_type/enums_mix_eq.jou @@ -0,0 +1,13 @@ +enum Foo: + Bar + Baz + +enum Color: + Red + Green + Bool + +def main() -> int: + if Foo.Baz == Color.Green: # Error: wrong types: cannot compare Foo and Color + pass + return 0