diff --git a/compiler/semtypes.nim b/compiler/semtypes.nim index cc16fd3c0e..bc3ddb0806 100644 --- a/compiler/semtypes.nim +++ b/compiler/semtypes.nim @@ -1501,7 +1501,10 @@ proc semProcTypeNode(c: PContext, n, genericParams: PNode, addParamOrResult(c, arg, kind) styleCheckDef(c, a[j].info, arg) onDef(a[j].info, arg) - a[j] = newSymNode(arg) + if a[j].kind == nkPragmaExpr: + a[j][0] = newSymNode(arg) + else: + a[j] = newSymNode(arg) var r: PType = nil if n[0].kind != nkEmpty: diff --git a/tests/pragmas/tparamcustompragma.nim b/tests/pragmas/tparamcustompragma.nim new file mode 100644 index 0000000000..b3e8151499 --- /dev/null +++ b/tests/pragmas/tparamcustompragma.nim @@ -0,0 +1,16 @@ +discard """ + nimout: ''' +proc foo(a {.attr.}: int) = + discard + +''' +""" + +# fixes #24702 + +import macros +template attr*() {.pragma.} +proc foo(a {.attr.}: int) = discard +macro showImpl(a: typed) = + echo repr getImpl(a) +showImpl(foo)