nim-works / nimskull

An in development statically typed systems programming language; with sustainability at its core. We, the community of users, maintain it.
https://nim-works.github.io/nimskull/index.html
Other
267 stars 38 forks source link

Compiler crash with bogus for loop #1369

Closed starsiderfox closed 3 weeks ago

starsiderfox commented 3 weeks ago

Example:

for a in b:
    echo a

Traceback:

/home/user/nimskull/compiler/nim.nim(89) handleCmdLine
/home/user/nimskull/compiler/front/main.nim(539) mainCommand
/home/user/nimskull/compiler/front/main.nim(491) compileToBackend
/home/user/nimskull/compiler/front/main.nim(214) commandCompileToC
/home/user/nimskull/compiler/modules/modules.nim(216) compileProject
/home/user/nimskull/compiler/modules/modules.nim(132) compileModule
/home/user/nimskull/compiler/sem/passes.nim(275) processModule
/home/user/nimskull/compiler/sem/passes.nim(102) processTopLevelStmt
/home/user/nimskull/compiler/sem/sem.nim(951) myProcess
/home/user/nimskull/compiler/sem/sem.nim(868) semStmtAndGenerateGenerics
/home/user/nimskull/compiler/sem/semstmts.nim(3386) semStmt
/home/user/nimskull/compiler/sem/semexprs.nim(1440) semExprNoType
/home/user/nimskull/compiler/sem/semexprs.nim(3835) semExpr
/home/user/nimskull/compiler/sem/semstmts.nim(3282) semStmtList
/home/user/nimskull/compiler/sem/semexprs.nim(3848) semExpr
/home/user/nimskull/compiler/sem/semstmts.nim(1639) semFor
/home/user/nimskull/compiler/sem/semstmts.nim(1600) semForVars
/home/user/nimskull/compiler/sem/semstmts.nim(95) semExprBranch
/home/user/nimskull/compiler/sem/semexprs.nim(3835) semExpr
/home/user/nimskull/compiler/sem/semstmts.nim(3282) semStmtList
/home/user/nimskull/compiler/sem/semexprs.nim(3848) semExpr
/home/user/nimskull/compiler/sem/semstmts.nim(1639) semFor
/home/user/nimskull/compiler/sem/semstmts.nim(1600) semForVars
/home/user/nimskull/compiler/sem/semstmts.nim(95) semExprBranch
/home/user/nimskull/compiler/sem/semexprs.nim(3835) semExpr
/home/user/nimskull/compiler/sem/semstmts.nim(3282) semStmtList
/home/user/nimskull/compiler/sem/semexprs.nim(3735) semExpr
/home/user/nimskull/compiler/sem/semexprs.nim(1254) semIndirectOp
/home/user/nimskull/compiler/sem/semexprs.nim(3702) semExpr
/home/user/nimskull/compiler/sem/semexprs.nim(1412) semDirectOp
/home/user/nimskull/compiler/sem/semexprs.nim(1145) semOverloadedCallAnalyseEffects
/home/user/nimskull/compiler/sem/semcall.nim(609) semOverloadedCall
/home/user/nimskull/compiler/sem/semcall.nim(539) semResolvedCall
/home/user/nimskull/lib/system/assertions.nim(38) failedAssertImpl
/home/user/nimskull/lib/system/assertions.nim(28) raiseAssert
/home/user/nimskull/lib/system/fatal.nim(50) sysFatal
Error: unhandled exception: /home/user/nimskull/compiler/ast/errorhandling.nim(139, 12) `e`gensym542 != nil` there must be an error node within [AssertionDefect]
mrgaturus commented 3 weeks ago

not reproducible on -d:danger builds of nimskull. is this a kind of inverse heisenbug?

zerbina commented 3 weeks ago

not reproducible on -d:danger builds of nimskull. is this a kind of inverse heisenbug?

In -d:danger builds, assertions are disabled, meaning that the assertion can never trigger. Since b is still wrapped in an error node, subsequent processing of the procedure is disabled, and a proper error is reported (it might not, I haven't tested it yet).

zerbina commented 3 weeks ago

Fixed by #1372.