mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-01 02:42:05 +00:00
@@ -639,8 +639,7 @@ proc semTemplateDef(c: PContext, n: PNode): PNode =
|
||||
for i in 1 .. s.typ.n.len-1:
|
||||
let param = s.typ.n.sons[i].sym
|
||||
param.flags.incl sfTemplateParam
|
||||
if optNimV019 in c.config.globalOptions:
|
||||
param.flags.excl sfGenSym
|
||||
param.flags.excl sfGenSym
|
||||
if param.typ.kind != tyUntyped: allUntyped = false
|
||||
if len(gp) > 0:
|
||||
if n.sons[genericParamsPos].kind == nkEmpty:
|
||||
|
||||
@@ -70,3 +70,21 @@ macro makeProc(): typed =
|
||||
makeProc()
|
||||
|
||||
someProc()
|
||||
|
||||
# bug #12193
|
||||
import macros, strutils
|
||||
|
||||
macro gen(T: typedesc): untyped =
|
||||
let typeSym = getTypeImpl(T)[1]
|
||||
let param = genSym(nskParam, "s")
|
||||
let value = nnkBracketExpr.newTree(param, newIntLitNode(0))
|
||||
result = newProc(
|
||||
name = ident"pack",
|
||||
params = [typeSym,
|
||||
newIdentDefs(param, nnkBracketExpr.newTree(ident"seq", ident"string"))],
|
||||
body = newStmtList(newCall(typeSym, newCall(bindSym"parseInt", value))),
|
||||
procType = nnkTemplateDef)
|
||||
echo repr result
|
||||
|
||||
gen(int)
|
||||
let i = pack(@["2"])
|
||||
|
||||
Reference in New Issue
Block a user