From 527e1c03b7f8523ca9de50612b3db5b5ef9d4af8 Mon Sep 17 00:00:00 2001 From: Alexander Medvednikov Date: Thu, 26 Feb 2026 11:31:32 +0300 Subject: [PATCH] checker: fix enum variant equality test is not commutative (fixes #10331) --- .../enums/enum_short_infix_commutative_test.v | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 vlib/v/tests/enums/enum_short_infix_commutative_test.v diff --git a/vlib/v/tests/enums/enum_short_infix_commutative_test.v b/vlib/v/tests/enums/enum_short_infix_commutative_test.v new file mode 100644 index 000000000..972e4b3a6 --- /dev/null +++ b/vlib/v/tests/enums/enum_short_infix_commutative_test.v @@ -0,0 +1,34 @@ +enum EnumCommutative { + a + b +} + +fn short_eq_left(x EnumCommutative) bool { + return .a == x +} + +fn short_eq_right(x EnumCommutative) bool { + return x == .a +} + +fn short_ne_left(x EnumCommutative) bool { + return .a != x +} + +fn short_ne_right(x EnumCommutative) bool { + return x != .a +} + +fn test_short_enum_infix_equality_is_commutative() { + assert short_eq_left(.a) + assert short_eq_right(.a) + assert !short_eq_left(.b) + assert !short_eq_right(.b) +} + +fn test_short_enum_infix_inequality_is_commutative() { + assert !short_ne_left(.a) + assert !short_ne_right(.a) + assert short_ne_left(.b) + assert short_ne_right(.b) +} -- 2.39.5