fixes #4097
This commit is contained in:
parent
79f64d2469
commit
8dfdea8919
3 changed files with 30 additions and 9 deletions
17
tests/template/typedescids.nim
Normal file
17
tests/template/typedescids.nim
Normal file
|
|
@ -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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue