fixes #24167; {.push deprecated.} for templates (#24170)

fixes #24167
This commit is contained in:
ringabout
2024-09-25 19:00:06 +08:00
committed by GitHub
parent b9de2bb4f3
commit 3b85c1a2e9
2 changed files with 11 additions and 2 deletions

View File

@@ -1057,8 +1057,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:

View File

@@ -124,3 +124,9 @@ foo31()
foo41()
{.pop.}
block:
{.push deprecated.}
template test() = discard
test()
{.pop.}