summary refs log tree commit diff stats
path: root/tests/global/globalaux.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/global/globalaux.nim')
-rw-r--r--tests/global/globalaux.nim15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/global/globalaux.nim b/tests/global/globalaux.nim
new file mode 100644
index 000000000..5f6f72721
--- /dev/null
+++ b/tests/global/globalaux.nim
@@ -0,0 +1,15 @@
+type 
+  TObj*[T] = object
+    val*: T
+
+var
+  totalGlobals* = 0
+
+proc makeObj[T](x: T): TObj[T] =
+  totalGlobals += 1
+  result.val = x
+
+proc globalInstance*[T]: var TObj[T] =
+  var g {.global.} = when T is int: makeObj(10) else: makeObj("hello")
+  result = g
+