summary refs log tree commit diff stats
path: root/tests/compile/tvoid.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/compile/tvoid.nim')
-rw-r--r--tests/compile/tvoid.nim33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/compile/tvoid.nim b/tests/compile/tvoid.nim
new file mode 100644
index 000000000..b286010dc
--- /dev/null
+++ b/tests/compile/tvoid.nim
@@ -0,0 +1,33 @@
+discard """
+  output: "he, no return type;abc a string"
+"""
+
+proc ReturnT[T](x: T): T =
+  when T is void:
+    echo "he, no return type;"
+  else:
+    result = x & " a string"
+
+proc nothing(x, y: void): void =
+  echo "ha"
+
+proc callProc[T](p: proc (x: T), x: T) =
+  when T is void: 
+    p()
+  else:
+    p(x)
+
+proc intProc(x: int) =
+  echo x
+  
+proc emptyProc() =
+  echo "empty"
+
+callProc[int](intProc, 12)
+callProc[void](emptyProc)
+
+
+ReturnT[void]()
+echo ReturnT[string]("abc")
+nothing()
+