tuple unpacking works in a non-var/let context

This commit is contained in:
Araq 2015-08-21 12:31:55 +02:00
commit bfd2fd67f9
5 changed files with 69 additions and 2 deletions

View file

@ -0,0 +1,32 @@
discard """
output: '''2 4
4
2 0'''
"""
proc foobar(): (int, int) = (2, 4)
# test within a proc:
proc pp(x: var int) =
var y: int
(y, x) = foobar()
template pt(x) =
var y: int
(x, y) = foobar()
# test within a generic:
proc pg[T](x, y: var T) =
pt(x)
# test as a top level statement:
var x, y, a, b: int
(x, y) = fooBar()
echo x, " ", y
pp(a)
echo a
pg(a, b)
echo a, " ", b