diff options
author | flywind <43030857+xflywind@users.noreply.github.com> | 2020-11-02 17:58:14 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-02 10:58:14 +0100 |
commit | 5b4c17b5e7166220c7b5c149946579f245f54645 (patch) | |
tree | 2b4e00ce46075dbf5d33d14c2d80d67da3749494 | |
parent | 544cb107c75523196ceee9408f9b1d5d89c82e48 (diff) | |
download | Nim-5b4c17b5e7166220c7b5c149946579f245f54645.tar.gz |
Closure iterators are not supported by VM (#15818)
-rw-r--r-- | compiler/vmgen.nim | 2 | ||||
-rw-r--r-- | tests/vm/tclosureiterator.nim | 9 |
2 files changed, 11 insertions, 0 deletions
diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim index 0c0c491e0..61c7fefd9 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 000000000..c909392d5 --- /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 |