summary refs log tree commit diff stats
path: root/tests/ccgbugs/tgeneric_closure.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ccgbugs/tgeneric_closure.nim')
-rw-r--r--tests/ccgbugs/tgeneric_closure.nim34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/ccgbugs/tgeneric_closure.nim b/tests/ccgbugs/tgeneric_closure.nim
new file mode 100644
index 000000000..9f3c5b446
--- /dev/null
+++ b/tests/ccgbugs/tgeneric_closure.nim
@@ -0,0 +1,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