diff --git a/compiler/pragmas.nim b/compiler/pragmas.nim index 06e8610841..101b17bf62 100644 --- a/compiler/pragmas.nim +++ b/compiler/pragmas.nim @@ -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: diff --git a/tests/pragmas/tcustom_pragma.nim b/tests/pragmas/tcustom_pragma.nim index db25361889..b624f32ba3 100644 --- a/tests/pragmas/tcustom_pragma.nim +++ b/tests/pragmas/tcustom_pragma.nim @@ -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.}