Skip to content

Commit

Permalink
Allow custom pragma on iterators [backport] (#20344)
Browse files Browse the repository at this point in the history
Allow custom pragma on iterators
  • Loading branch information
Menduist authored Sep 16, 2022
1 parent d44b547 commit 3a5e38a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/pragmas.nim
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,7 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int,
elif comesFromPush and whichKeyword(ident) != wInvalid:
discard "ignore the .push pragma; it doesn't apply"
else:
if sym == nil or (sym.kind in {skVar, skLet, skParam,
if sym == nil or (sym.kind in {skVar, skLet, skParam, skIterator,
skField, skProc, skFunc, skConverter, skMethod, skType}):
n[i] = semCustomPragma(c, it)
elif sym != nil:
Expand Down
7 changes: 7 additions & 0 deletions tests/pragmas/tcustom_pragma.nim
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,13 @@ block:

discard Hello(a: 1.0, b: 12)

# custom pragma on iterators
block:
template prag {.pragma.}
{.push prag.}
proc hello = discard
iterator hello2: int = discard

# issue #11511
when false:
template myAttr {.pragma.}
Expand Down

0 comments on commit 3a5e38a

Please sign in to comment.