summary refs log tree commit diff stats
path: root/tests/parser/ttupleunpack.nim
blob: aaa06f9f41fdbc8b8a7fa6eff96db32f01cc4a53 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
discard """
  file: "ttupleunpack.nim"
  output: ""
  exitcode: 0
"""

proc returnsTuple(): (int, int, int) = (4, 2, 3)

proc main2 =
  let (x, _, z) = returnsTuple()

proc main() =

  proc foo(): tuple[x, y, z: int] =
    return (4, 2, 3)

  var (x, _, y) = foo()
  doAssert x == 4
  doAssert y == 3

  var (a, _, _) = foo()
  doAssert a == 4

  var (aa, _, _) = foo()
  doAssert aa == 4

  iterator bar(): tuple[x, y, z: int] =
    yield (1,2,3)

  for x, y, _ in bar():
    doAssert x == 1
    doAssert y == 2

main()
main2()