cgen: fix array.index() of ref struct (#7652)

This commit is contained in:
yuyi 2020-12-29 01:33:57 +08:00 committed by GitHub
parent 93262353d6
commit 9631eac9c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 43 additions and 38 deletions

View file

@ -1278,3 +1278,15 @@ fn test_array_struct_ref_contains() {
println(exists)
assert exists == true
}
fn test_array_struct_ref_index() {
mut coords := []&Coord{}
coord_1 := &Coord{
x: 1
y: 2
z: -1
}
coords << coord_1
println(coords.index(coord_1))
assert coords.index(coord_1) == 0
}