Skip to content

Commit

Permalink
follow nim-lang#15818 and close nim-lang#7109
Browse files Browse the repository at this point in the history
  • Loading branch information
ringabout committed Nov 2, 2020
1 parent dfd8a83 commit be3583e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 5 additions & 2 deletions compiler/jsgen.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2549,17 +2549,20 @@ proc gen(p: PProc, n: PNode, r: var TCompRes) =
of nkAsmStmt: genAsmOrEmitStmt(p, n)
of nkTryStmt, nkHiddenTryStmt: genTry(p, n, r)
of nkRaiseStmt: genRaiseStmt(p, n)
of nkTypeSection, nkCommentStmt, nkIteratorDef, nkIncludeStmt,
of nkTypeSection, nkCommentStmt, nkIncludeStmt,
nkImportStmt, nkImportExceptStmt, nkExportStmt, nkExportExceptStmt,
nkFromStmt, nkTemplateDef, nkMacroDef, nkStaticStmt: discard
of nkIteratorDef:
if n[0].sym.typ.callConv == TCallingConvention.ccClosure:
globalError(p.config, n.info, "Closure iterators are not supported by JS backend!")
of nkPragma: genPragma(p, n)
of nkProcDef, nkFuncDef, nkMethodDef, nkConverterDef:
var s = n[namePos].sym
if {sfExportc, sfCompilerProc} * s.flags == {sfExportc}:
genSym(p, n[namePos], r)
r.res = nil
of nkGotoState, nkState:
internalError(p.config, n.info, "first class iterators not implemented")
globalError(p.config, n.info, "first class iterators not implemented")
of nkPragmaBlock: gen(p, n.lastSon, r)
of nkComesFrom:
discard "XXX to implement for better stack traces"
Expand Down
8 changes: 8 additions & 0 deletions tests/js/t7109.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
discard """
errormsg: "Closure iterators are not supported by JS backend!"
"""

iterator iter*(): int {.closure.} =
yield 3

var x = iter

0 comments on commit be3583e

Please sign in to comment.