keep param pragmas in typed proc AST (#24711)

fixes #24702

(cherry picked from commit 1f8da3835f)
This commit is contained in:
metagn
2025-02-22 23:22:30 +03:00
committed by narimiran
parent 51edd9bd60
commit d3780bb7bd
2 changed files with 20 additions and 1 deletions

View File

@@ -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:

View File

@@ -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)