Skip to content

Commit

Permalink
keep param pragmas in typed proc AST (nim-lang#24711)
Browse files Browse the repository at this point in the history
  • Loading branch information
metagn authored Feb 22, 2025
1 parent 1af88a2 commit 1f8da38
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
5 changes: 4 additions & 1 deletion compiler/semtypes.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
16 changes: 16 additions & 0 deletions tests/pragmas/tparamcustompragma.nim
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 1f8da38

Please sign in to comment.