Skip to content

Codegen ICE in allPathsAsgnResult #12827

Closed
@cooldome

Description

@cooldome

Compile with --gc:destructors

import streams

type
  MyObject = object
    x: string
    y: seq[string]
    needs_ref: ref int

proc xx(xml: string): MyObject =
  let stream = newStringStream(xml)
  result.y.add readLine(stream)
  defer: close(stream)
 
discard xx("asdfasdfasdf")

Compiler crash with stacktace:

C:\Nim\compiler\nim.nim(106) nim
C:\Nim\compiler\nim.nim(83) handleCmdLine
C:\Nim\compiler\cmdlinehelper.nim(98) loadConfigsAndRunMainCommand
C:\Nim\compiler\main.nim(188) mainCommand
C:\Nim\compiler\main.nim(92) commandCompileToC
C:\Nim\compiler\modules.nim(144) compileProject
C:\Nim\compiler\modules.nim(85) compileModule
C:\Nim\compiler\passes.nim(210) processModule
C:\Nim\compiler\passes.nim(86) processTopLevelStmt
C:\Nim\compiler\cgen.nim(1880) myProcess
C:\Nim\compiler\ccgstmts.nim(1275) genStmts
C:\Nim\compiler\ccgexprs.nim(2618) expr
C:\Nim\compiler\ccgexprs.nim(2403) genStmtList
C:\Nim\compiler\ccgstmts.nim(1275) genStmts
C:\Nim\compiler\ccgexprs.nim(2666) expr
C:\Nim\compiler\ccgstmts.nim(1036) genTry
C:\Nim\compiler\ccgexprs.nim(2659) expr
C:\Nim\compiler\cgen.nim(602) initLocExprSingleUse
C:\Nim\compiler\ccgexprs.nim(2617) expr
C:\Nim\compiler\ccgexprs.nim(2392) genStmtListExpr
C:\Nim\compiler\ccgstmts.nim(1275) genStmts
C:\Nim\compiler\ccgexprs.nim(2582) expr
C:\Nim\compiler\ccgcalls.nim(568) genCall
C:\Nim\compiler\ccgcalls.nim(194) genPrefixCall
C:\Nim\compiler\ccgcalls.nim(162) genArg
C:\Nim\compiler\cgen.nim(589) initLocExpr
C:\Nim\compiler\ccgexprs.nim(2588) expr
C:\Nim\compiler\ccgcalls.nim(568) genCall
C:\Nim\compiler\ccgcalls.nim(207) genPrefixCall
C:\Nim\compiler\cgen.nim(589) initLocExpr
C:\Nim\compiler\ccgexprs.nim(2518) expr
C:\Nim\compiler\cgen.nim(1183) genProc
C:\Nim\compiler\cgen.nim(1148) genProcNoForward
C:\Nim\compiler\cgen.nim(1003) genProcAux
C:\Nim\compiler\cgen.nim(882) allPathsAsgnResult
C:\Nim\compiler\cgen.nim(870) allPathsAsgnResult
C:\Nim\compiler\cgen.nim(952) allPathsAsgnResult
C:\Nim\compiler\ast.nim(1239) lastSon
C:\Nim\lib\system.nim(4025) []
C:\Nim\lib\system\fatal.nim(39) sysFatal
Error: unhandled exception: index out of bounds, the container is empty [IndexError]

I don't think error is --gc:desctuctors specific.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions