diff --git a/vlib/builtin/array_test.v b/vlib/builtin/array_test.v index 7b992f7ec4..3a2b70d22d 100644 --- a/vlib/builtin/array_test.v +++ b/vlib/builtin/array_test.v @@ -1251,3 +1251,24 @@ fn test_struct_array_of_multi_type_index() { println(people.index(ivan)) assert people.index(ivan) == 0 } + +struct Coord { + x int + y int + z int +} + +fn test__array_struct_contains() { + mut coords := []Coord{} + coord_1 := Coord{ + x: 1 + y: 2 + z: -1 + } + coords << coord_1 + exists := coord_1 in coords + not_exists := coord_1 !in coords + println('`exists`: $exists and `not exists`: $not_exists') + assert exists == true + assert not_exists == false +} diff --git a/vlib/v/gen/auto_eq_methods.v b/vlib/v/gen/auto_eq_methods.v index 656b441c23..8282dabad1 100644 --- a/vlib/v/gen/auto_eq_methods.v +++ b/vlib/v/gen/auto_eq_methods.v @@ -38,7 +38,7 @@ fn (mut g Gen) gen_struct_equality_fn(left table.Type) string { fn_builder.writeln('\tif (*((voidptr*)(a.$field.name)) != *((voidptr*)(b.$field.name))) {') } else { - fn_builder.writeln('\tif (a.$field.name != b.$field.name)) {') + fn_builder.writeln('\tif (a.$field.name != b.$field.name) {') } } fn_builder.writeln('\t\treturn false;')