Skip to content

Commit

Permalink
fixes #24167; {.push deprecated.} for templates
Browse files Browse the repository at this point in the history
  • Loading branch information
ringabout committed Sep 25, 2024
1 parent b9de2bb commit d32e337
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 3 additions & 1 deletion compiler/pragmas.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1357,7 +1357,9 @@ proc implicitPragmas*(c: PContext, sym: PSym, info: TLineInfo,
internalError(c.config, info, "implicitPragmas")
inc i
popInfoContext(c.config)
if sym.kind in routineKinds and sym.ast != nil: mergePragmas(sym.ast, o)
if sym.kind in routineKinds-{skTemplate} and sym.ast != nil and
not (sym.kind == skTemplate and sfGenSym in sym.flags):
mergePragmas(sym.ast, o)

if lfExportLib in sym.loc.flags and sfExportc notin sym.flags:
localError(c.config, info, ".dynlib requires .exportc")
Expand Down
12 changes: 7 additions & 5 deletions compiler/semtempl.nim
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,13 @@ proc semTemplateDef(c: PContext, n: PNode): PNode =
pushOwner(c, s)
openScope(c)
n[namePos] = newSymNode(s)

# <del> set the symbol AST after pragmas, at least. This stops pragma that have
# been pushed (implicit) to be explicitly added to the template definition
# and misapplied to the body. see #18113 </del>
# I changed it back and disable implicit pragams for sfGenSym templates
s.ast = n

pragmaCallable(c, s, n, templatePragmas)
implicitPragmas(c, s, n.info, templatePragmas)

Expand Down Expand Up @@ -763,11 +770,6 @@ proc semTemplateDef(c: PContext, n: PNode): PNode =
closeScope(c)
popOwner(c)

# set the symbol AST after pragmas, at least. This stops pragma that have
# been pushed (implicit) to be explicitly added to the template definition
# and misapplied to the body. see #18113
s.ast = n

if sfCustomPragma in s.flags:
if n[bodyPos].kind != nkEmpty:
localError(c.config, n[bodyPos].info, errImplOfXNotAllowed % s.name.s)
Expand Down

0 comments on commit d32e337

Please sign in to comment.