summary refs log tree commit diff stats
path: root/tests/generics/tgenericlambda.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/generics/tgenericlambda.nim')
-rw-r--r--tests/generics/tgenericlambda.nim23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/generics/tgenericlambda.nim b/tests/generics/tgenericlambda.nim
new file mode 100644
index 000000000..41ee74557
--- /dev/null
+++ b/tests/generics/tgenericlambda.nim
@@ -0,0 +1,23 @@
+discard """
+  output: "10\n10\n1\n2\n3\n15"
+"""
+
+proc test(x: proc (a, b: int): int) =
+  echo x(5, 5)
+
+test(proc (a, b: auto): auto = a + b)
+
+test do (a, b: auto) -> auto: a + b
+
+proc foreach[T](s: seq[T], body: proc(x: T)) =
+  for e in s:
+    body(e)
+
+foreach(@[1,2,3]) do (x: auto):
+  echo x
+
+proc foo =
+  let x = proc (a, b: int): auto = a + b
+  echo x(5, 10)
+
+foo()