Skip to content

Recursively calling a closure iterator results in a compiler crash #555

@dom96

Description

@dom96
iterator test(x: int): int {.closure.} =
  var b = test
  if x == 5: yield 1
  else:
    yield b(x+1)

var t = test
echo t()

Crashes with:

Traceback (most recent call last)
nimrod.nim(79)           nimrod
nimrod.nim(55)           HandleCmdLine
main.nim(296)            MainCommand
main.nim(72)             CommandCompileToC
modules.nim(193)         CompileProject
modules.nim(151)         compileModule
passes.nim(192)          processModule
passes.nim(136)          processTopLevelStmt
sem.nim(300)             myProcess
sem.nim(274)             SemStmtAndGenerateGenerics
semstmts.nim(1238)       semStmt
semexprs.nim(778)        semExprNoType
semexprs.nim(1939)       semExpr
semstmts.nim(1055)       semIterator
semstmts.nim(1026)       semProcAux
transf.nim(710)          transformBody
transf.nim(694)          processTransf
transf.nim(682)          transform
transf.nim(108)          transformSons
transf.nim(668)          transform
transf.nim(108)          transformSons
transf.nim(677)          transform
transf.nim(108)          transformSons
transf.nim(594)          transform
transf.nim(135)          transformSym
transf.nim(117)          transformSymAux
lambdalifting.nim(715)   liftIterSym
lambdalifting.nim(218)   getHiddenParam
system.nim(2501)         hiddenRaiseAssert
system.nim(1804)         raiseAssert
Error: unhandled exception: hidden.Kind == nkSym  [EAssertionFailed]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions