mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-12 04:09:34 +00:00
closes #22842, closes #21252, closes #19312, closes #16956, closes #16416, closes #14913, closes #13296, closes #12424, closes #10902, closes #9892, closes #9617
32 lines
664 B
Nim
32 lines
664 B
Nim
discard """
|
|
output: '''done'''
|
|
"""
|
|
# Issue #10902: cannot instantiate T when generating AST from macro
|
|
# https://github.com/nim-lang/Nim/issues/10902
|
|
|
|
import macros
|
|
|
|
type
|
|
Base[T] = ref object
|
|
|
|
macro genCloneProc(typeWithGenArg: untyped): untyped =
|
|
result = newProc(
|
|
ident "clone", [
|
|
typeWithGenArg,
|
|
newIdentDefs(
|
|
ident "self",
|
|
typeWithGenArg,
|
|
)
|
|
],
|
|
newStmtList(
|
|
newNimNode(nnkDiscardStmt).add(newEmptyNode())
|
|
)
|
|
)
|
|
let genericParamIdent = typeWithGenArg[1]
|
|
result[2] = newNimNode(nnkGenericParams)
|
|
result[2].add(newIdentDefs(genericParamIdent, newEmptyNode()))
|
|
|
|
genCloneProc(Base[T])
|
|
|
|
echo "done"
|