diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim index aa8cd43477..21c19c2b19 100644 --- a/compiler/vmgen.nim +++ b/compiler/vmgen.nim @@ -1982,6 +1982,8 @@ proc gen(c: PCtx; n: PNode; dest: var TDest; flags: TGenFlags = {}) = genRdVar(c, n, dest, flags) of skProc, skFunc, skConverter, skMacro, skTemplate, skMethod, skIterator: # 'skTemplate' is only allowed for 'getAst' support: + if s.kind == skIterator and s.typ.callConv == TCallingConvention.ccClosure: + globalError(c.config, n.info, "Closure iterators are not supported by VM!") if procIsCallback(c, s): discard elif importcCond(s): c.importcSym(n.info, s) genLit(c, n, dest) diff --git a/tests/vm/tclosureiterator.nim b/tests/vm/tclosureiterator.nim new file mode 100644 index 0000000000..c909392d55 --- /dev/null +++ b/tests/vm/tclosureiterator.nim @@ -0,0 +1,9 @@ +discard """ + errormsg: "Closure iterators are not supported by VM!" +""" + +iterator iter*(): int {.closure.} = + yield 3 + +static: + var x = iter