File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 1+ struct MyInt {
2+ x int
3+ }
4+
5+ fn (i1 MyInt) == (i2 MyInt) bool {
6+ return i1 .x == i2 .x
7+ }
8+
9+ fn test_main () {
10+ c := MyInt{30 } == MyInt{2 }
11+ assert ! c
12+ }
Original file line number Diff line number Diff line change @@ -1137,7 +1137,8 @@ pub fn (mut t Transformer) infix_expr(mut node ast.InfixExpr) ast.Expr {
11371137 // for `a == a`, `a != a`, `struct.f != struct.f`
11381138 // Note: can't compare `f32` or `f64` here, as `NaN != NaN` will return true in IEEE 754
11391139 if node.left.type_name () == node.right.type_name ()
1140- && node.left_type ! in [ast.f32_ type, ast.f64_ type] && node.op in [.eq, .ne] {
1140+ && node.left_type ! in [ast.f32_ type, ast.f64_ type] && node.op in [.eq, .ne]
1141+ && node.left ! is ast.StructInit && node.right ! is ast.StructInit {
11411142 left_name := '${node.left} '
11421143 right_name := '${node.right} '
11431144 if left_name == right_name {
You can’t perform that action at this time.
0 commit comments