Skip to content

Nim crash; constant array of refs is not reported as an error #5870

@Tormund

Description

@Tormund

Nim is crashing when I compile this code

    type SomeRefObj = ref object of RootObj
        someIntMember: int

    proc createSomeRefObj(v: int): SomeRefObj=
        result.new()
        result.someIntMember = v

    const compileTimeSeqOfRefObjs = @[createSomeRefObj(100500), createSomeRefObj(2)]

With this stack-trace:

nim.nim(121)             nim
nim.nim(77)              handleCmdLine
main.nim(163)            mainCommand
main.nim(74)             commandCompileToC
modules.nim(240)         compileProject
modules.nim(180)         compileModule
passes.nim(215)          processModule
passes.nim(135)          processTopLevelStmt
sem.nim(549)             myProcess
sem.nim(521)             semStmtAndGenerateGenerics
semstmts.nim(1790)       semStmt
semexprs.nim(812)        semExprNoType
semexprs.nim(2371)       semExpr
importer.nim(212)        evalImport
importer.nim(191)        impMod
importer.nim(177)        myImportModule
modules.nim(203)         importModule
modules.nim(180)         compileModule
passes.nim(215)          processModule
passes.nim(135)          processTopLevelStmt
cgen.nim(1297)           myProcess
ccgstmts.nim(1126)       genStmts
ccgexprs.nim(2086)       expr
ccgstmts.nim(1126)       genStmts
ccgexprs.nim(2109)       expr
ccgstmts.nim(274)        genConstStmt
cgen.nim(805)            requestConstImpl
ccgexprs.nim(2272)       genConstExpr
ccgexprs.nim(2245)       genConstSeq
ccgexprs.nim(2276)       genConstExpr
ccgexprs.nim(2225)       genConstObjConstr
ccgexprs.nim(2196)       getNullValueAux
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

nim git revision: 2b8a1ce

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