1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: fix in in mutable arrays (#5647)

This commit is contained in:
yuyi
2020-07-04 18:12:44 +08:00
committed by GitHub
parent 56ad6cef54
commit 27149ba8bc
2 changed files with 17 additions and 2 deletions

View File

@@ -883,10 +883,10 @@ fn mut_arr_with_eq_in_fn(mut a []int) {
a[0] = 0
}
if [0,2,3,4] == a {
a[1] = 0
a[1] = 0
}
if !(a != [0,0,3,4]) {
a[2] = 0
a[2] = 0
}
if !([0,0,0,4] != a) {
a[3] = 0
@@ -898,3 +898,15 @@ fn test_mut_arr_with_eq_in_fn() {
mut_arr_with_eq_in_fn(mut a)
assert a == [0,0,0,0]
}
fn array_in_mut(mut a []int) {
if 1 in a {
a[0] = 2
}
}
fn test_array_in_mut() {
mut a := [1,2]
array_in_mut(mut a)
assert a == [2,2]
}