tuple unpacking works in a non-var/let context
This commit is contained in:
parent
2733c508ef
commit
bfd2fd67f9
5 changed files with 69 additions and 2 deletions
32
tests/tuples/tunpack_asgn.nim
Normal file
32
tests/tuples/tunpack_asgn.nim
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue