Skip to content

Commit

Permalink
fixes #24167; {.push deprecated.} for templates (#24170)
Browse files Browse the repository at this point in the history
fixes #24167

(cherry picked from commit 3b85c1a)
  • Loading branch information
ringabout authored and narimiran committed Sep 28, 2024
1 parent 3a180df commit 1ba1687
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 5 additions & 2 deletions compiler/ast.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1258,8 +1258,11 @@ proc getDeclPragma*(n: PNode): PNode =

proc extractPragma*(s: PSym): PNode =
## gets the pragma node of routine/type/var/let/const symbol `s`
if s.kind in routineKinds:
result = s.ast[pragmasPos]
if s.kind in routineKinds: # bug #24167
if s.ast[pragmasPos] != nil and s.ast[pragmasPos].kind != nkEmpty:
result = s.ast[pragmasPos]
else:
result = nil
elif s.kind in {skType, skVar, skLet, skConst}:
if s.ast != nil and s.ast.len > 0:
if s.ast[0].kind == nkPragmaExpr and s.ast[0].len > 1:
Expand Down
6 changes: 6 additions & 0 deletions tests/pragmas/tpush.nim
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,9 @@ foo31()
foo41()

{.pop.}

block:
{.push deprecated.}
template test() = discard
test()
{.pop.}

0 comments on commit 1ba1687

Please sign in to comment.