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

parser: fix array cross assign (fix #5577) (#5591)

This commit is contained in:
yuyi
2020-07-01 18:11:03 +08:00
committed by GitHub
parent 7386adfc99
commit 6c5b638202
6 changed files with 66 additions and 3 deletions

View File

@@ -877,3 +877,16 @@ fn test_plus_assign_string() {
a[0] += 'abc'
assert a == ['abc']
}
fn test_cross_assign() {
mut a := [0, 1]
a[0], a[1] = a[1], a[0]
assert a[0] == 1
assert a[1] == 0
mut b1 := [1, 2, 3]
mut b2 := 4
b1[2], b2, b1[0] = b1[0], b1[2], 5
assert b1 == [5, 2, 1]
assert b2 == 3
}