cgen: fix generic contains method (#7618)
parent
ed6ba0a2b8
commit
d87011ab78
|
@ -1251,3 +1251,24 @@ fn test_struct_array_of_multi_type_index() {
|
||||||
println(people.index(ivan))
|
println(people.index(ivan))
|
||||||
assert people.index(ivan) == 0
|
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
|
||||||
|
}
|
||||||
|
|
|
@ -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))) {')
|
fn_builder.writeln('\tif (*((voidptr*)(a.$field.name)) != *((voidptr*)(b.$field.name))) {')
|
||||||
}
|
}
|
||||||
else {
|
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;')
|
fn_builder.writeln('\t\treturn false;')
|
||||||
|
|
Loading…
Reference in New Issue