From 8dfdea89199012f69c844592d2abb9427b5f3041 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Tue, 19 Apr 2016 11:56:35 +0200 Subject: fixes #4097 --- tests/template/typedescids.nim | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 tests/template/typedescids.nim (limited to 'tests/template') 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) -- cgit 1.4.1-2-gfad0