diff options
author | Araq <rumpf_a@web.de> | 2015-08-21 12:31:55 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2015-08-21 21:34:14 +0200 |
commit | bfd2fd67f948f6a5ee8815ee866d55d147f53c73 (patch) | |
tree | d03fdbac18566c26c4a9dffd74c270949889a8c9 /tests/tuples/tunpack_asgn.nim | |
parent | 2733c508ef2681fe8eddfe9c73419ef3226e479d (diff) | |
download | Nim-bfd2fd67f948f6a5ee8815ee866d55d147f53c73.tar.gz |
tuple unpacking works in a non-var/let context
Diffstat (limited to 'tests/tuples/tunpack_asgn.nim')
-rw-r--r-- | tests/tuples/tunpack_asgn.nim | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/tuples/tunpack_asgn.nim b/tests/tuples/tunpack_asgn.nim new file mode 100644 index 000000000..a48fcff5d --- /dev/null +++ b/tests/tuples/tunpack_asgn.nim @@ -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 |