mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-27 17:11:40 +00:00
25 lines
300 B
Nim
25 lines
300 B
Nim
discard """
|
|
output: '''
|
|
(v: 3)
|
|
'''
|
|
"""
|
|
|
|
import typetraits
|
|
type
|
|
A[T] = ref object
|
|
v: T
|
|
|
|
template templ(o: A, op: untyped): untyped =
|
|
type T = typeof(o.v)
|
|
|
|
var res: A[T]
|
|
|
|
block:
|
|
var it {.inject.}: T
|
|
it = o.v
|
|
res = A[T](v: op)
|
|
res
|
|
|
|
let a = A[int](v: 1)
|
|
echo templ(a, it + 2)[]
|