Nim
Nim copied to clipboard
ICE when trying to repr nnkMutableTy in macro
Had a bug that appeared in a test case of shell a few months ago. Finally took a look at what's going on.
I have a test case that has a --out in its argument. It seems that at some point trying to repr a nnkMutableTy (the node of out, at least nowadays) became an internal compiler error.
Example
import macros
macro print(n: untyped): untyped =
echo n.treeRepr # works
echo n.repr # sigsegv
print:
out
Current Output
StmtList
MutableTy
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Expected Output
StmtList
MutableTy
out # or maybe something else, but no ICE :)
Additional Information
I'm on current devel right now and the problem persists.
Nim Compiler Version 1.5.1 [Linux: amd64]
Compiled at 2020-10-27
Copyright (c) 2006-2020 by Andreas Rumpf
git hash: 0fb878324eeb39a4707be5ab0fd6ad8412950b78
active boot switches: -d:release -d:danger
I definitely know that it worked in the past. I don't have a specific commit, but the first failure on Travis was (oh my god, time flies) April 20.
Output of koch temp:
StmtList
MutableTy
/home/basti/src/nim/nim_git_repo/compiler/nim.nim(118) nim
/home/basti/src/nim/nim_git_repo/compiler/nim.nim(83) handleCmdLine
/home/basti/src/nim/nim_git_repo/compiler/main.nim(240) mainCommand
/home/basti/src/nim/nim_git_repo/compiler/main.nim(205) compileToBackend
/home/basti/src/nim/nim_git_repo/compiler/main.nim(86) commandCompileToC
/home/basti/src/nim/nim_git_repo/compiler/modules.nim(158) compileProject
/home/basti/src/nim/nim_git_repo/compiler/modules.nim(94) compileModule
/home/basti/src/nim/nim_git_repo/compiler/passes.nim(196) processModule
/home/basti/src/nim/nim_git_repo/compiler/passes.nim(73) processTopLevelStmt
/home/basti/src/nim/nim_git_repo/compiler/sem.nim(601) myProcess
/home/basti/src/nim/nim_git_repo/compiler/sem.nim(569) semStmtAndGenerateGenerics
/home/basti/src/nim/nim_git_repo/compiler/semstmts.nim(2294) semStmt
/home/basti/src/nim/nim_git_repo/compiler/semexprs.nim(1028) semExprNoType
/home/basti/src/nim/nim_git_repo/compiler/semexprs.nim(2838) semExpr
/home/basti/src/nim/nim_git_repo/compiler/semstmts.nim(2236) semStmtList
/home/basti/src/nim/nim_git_repo/compiler/semexprs.nim(2726) semExpr
/home/basti/src/nim/nim_git_repo/compiler/semexprs.nim(1010) semDirectOp
/home/basti/src/nim/nim_git_repo/compiler/semexprs.nim(892) afterCallActions
/home/basti/src/nim/nim_git_repo/compiler/sem.nim(471) semMacroExpr
/home/basti/src/nim/nim_git_repo/compiler/vm.nim(2291) evalMacroCall
/home/basti/src/nim/nim_git_repo/compiler/vm.nim(1432) rawExecute
/home/basti/src/nim/nim_git_repo/compiler/renderer.nim(1629) renderTree
/home/basti/src/nim/nim_git_repo/compiler/renderer.nim(662) gstmts
/home/basti/src/nim/nim_git_repo/compiler/renderer.nim(574) gsub
/home/basti/src/nim/nim_git_repo/compiler/renderer.nim(1619) gsub
/home/basti/src/nim/nim_git_repo/compiler/msgs.nim(585) internalErrorImpl
/home/basti/src/nim/nim_git_repo/compiler/msgs.nim(525) liMessage
/home/basti/src/nim/nim_git_repo/compiler/msgs.nim(281) toFileLineCol
/home/basti/src/nim/nim_git_repo/compiler/msgs.nim(266) toMsgFilename
/home/basti/src/nim/nim_git_repo/compiler/msgs.nim(249) toFilenameOption
/home/basti/src/nim/nim_git_repo/compiler/msgs.nim(200) toFullPath
/home/basti/src/nim/nim_git_repo/lib/system/fatal.nim(49) sysFatal
Error: unhandled exception: index out of bounds, the container is empty [IndexDefect]
FAILURE
Heh, I had the same error a few days ago, the issue is that the renderer is using internalError but only has an empty config created with newPartialConfigRef which makes internalError crash while accessing the fileInfos for printiing.
The other issue that actually causes the call to internalError is that this node kind simply isn't handled yet in the renderer :D
Is this still an issue?