Skip to content

Using var PNimrodNode in a compiletime proc causes compiler crash #926

@dom96

Description

@dom96
import macros

proc test(f: var PNimrodNode) {.compileTime.} =
  f = newNimNode(nnkStmtList)
  f.add newCall(newIdentNode("echo"), newLit(5))

macro blah(prc: stmt): stmt =
  result = prc

  test(result)

proc test() {.blah.} =
  echo 5
Traceback (most recent call last)
nimrod.nim(87)           nimrod
nimrod.nim(55)           handleCmdLine
main.nim(308)            mainCommand
main.nim(73)             commandCompileToC
modules.nim(193)         compileProject
modules.nim(151)         compileModule
passes.nim(192)          processModule
passes.nim(136)          processTopLevelStmt
sem.nim(381)             myProcess
sem.nim(355)             semStmtAndGenerateGenerics
semstmts.nim(1290)       semStmt
semexprs.nim(826)        semExprNoType
semexprs.nim(1949)       semExpr
semexprs.nim(1542)       semWhen
semstmts.nim(1290)       semStmt
semexprs.nim(826)        semExprNoType
semexprs.nim(2009)       semExpr
semstmts.nim(1249)       semStmtList
semexprs.nim(2027)       semExpr
semstmts.nim(1119)       semProc
semstmts.nim(948)        semProcAux
semstmts.nim(868)        semProcAnnotation
semstmts.nim(1290)       semStmt
semexprs.nim(826)        semExprNoType
semexprs.nim(1915)       semExpr
sem.nim(288)             semMacroExpr
vm.nim(1192)             evalMacroCall
vm.nim(425)              rawExecute
system.nim(2588)         failedAssertImpl
system.nim(1855)         raiseAssert
Error: unhandled exception: regs[rb].kind == nkRefTy  [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