summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2016-04-19 11:56:35 +0200
committerAndreas Rumpf <rumpf_a@web.de>2016-04-19 11:56:35 +0200
commit8dfdea89199012f69c844592d2abb9427b5f3041 (patch)
tree6324d29fd9f8545e9fadbbab9691df19eb92d423 /tests
parent79f64d246925c19365eb27aa4571d4cb25ede312 (diff)
downloadNim-8dfdea89199012f69c844592d2abb9427b5f3041.tar.gz
fixes #4097
Diffstat (limited to 'tests')
-rw-r--r--tests/template/typedescids.nim17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/template/typedescids.nim b/tests/template/typedescids.nim
new file mode 100644
index 000000000..ebed49b17
--- /dev/null
+++ b/tests/template/typedescids.nim
@@ -0,0 +1,17 @@
+discard """
+  output: '''2 3'''
+"""
+
+# bug #4097
+
+var i {.compileTime.} = 2
+
+template defineId*(t: typedesc): stmt =
+  const id {.genSym.} = i
+  static: inc(i)
+  proc idFor*(T: typedesc[t]): int {.inline, raises: [].} = id
+
+defineId(int8)
+defineId(int16)
+
+echo idFor(int8), " ", idFor(int16)