Tuple unpacking now works for for vars (#10152)

* Tuple unpacking now works for `for` vars
* Give error if length of tuple vars != length of tuple
* Fix error message showing wrong tuple length
* unpacking now works now for mutable items
* Update changelog
This commit is contained in:
Neelesh Chandola 2019-02-23 18:31:34 +05:30 • committed by Andreas Rumpf
commit 9884129058
7 changed files with 156 additions and 45 deletions

View file

@ -0,0 +1,39 @@
discard """
output: '''
123
113283
0
123
1
113283
@[(88, 99, 11), (88, 99, 11)]
@[(7, 6, -28), (7, 6, -28)]
'''
"""
let t1 = (1, 2, 3)
let t2 = (11, 32, 83)
let s = @[t1, t2]
for (a, b, c) in s:
echo a, b, c
for i, (a, b, c) in s:
echo i
echo a, b, c
var x = @[(1,2,3), (4,5,6)]
for (a, b, c) in x.mitems:
a = 88
b = 99
c = 11
echo x
for i, (a, b, c) in x.mpairs:
a = 7
b = 6
c = -28
echo x