Closure iterators are not supported by VM (#15818)

(cherry picked from commit 5b4c17b5e7)
This commit is contained in:
flywind
2020-11-02 17:58:14 +08:00
committed by narimiran
parent 45e87ade15
commit 9d9bf12e1c
2 changed files with 11 additions and 0 deletions

View File

@@ -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)

View File

@@ -0,0 +1,9 @@
discard """
errormsg: "Closure iterators are not supported by VM!"
"""
iterator iter*(): int {.closure.} =
yield 3
static:
var x = iter