summary refs log tree commit diff stats
path: root/tests/ccgbugs/tgeneric_closure.nim
blob: 9f3c5b446ce9161631f594081ca09caecbd16ebc (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
discard """
output: '''
2
2
2
'''
"""

# bug 2659

type
  GenProcType[T,U] = proc(x:T, y:var U)
  IntProcType = proc(x:int, y:var int)

proc mult(x:int, y:var int) =
  y = 2 * x

when true:

  var input = 1
  var output = 0

  var someIntProc:IntProcType = mult
  var someGenProc:GenProcType[int,int] = mult

  mult(input, output)
  echo output

  someIntProc(input, output)
  echo output

  # Uncommenting causes an error in the C compiler.
  someGenProc(input, output)
  echo output