When the reference variable is parameter, pragma {.dirty.} cannot helpful. template t1() {.dirty.} = echo i template t2(i: int) {.dirty.} = t1() proc p1() = t2(x) when isMainModule: p1() Run
Compile output: D:\Tool\Nim\tmp\a59.nim(8, 6) template/generic instantiation of `t2` from here D:\Tool\Nim\tmp\a59.nim(2, 9) Error: undeclared identifier: 'i' Run