Skip to content

SIGSEGV when passing empty nskType to typedesc parameter #1523

Open
@alaviss

Description

@alaviss

Example

import macros

template foo(T: typedesc): untyped = discard

macro doFoo(): untyped =
  let sym = nskType.genSym()
  result = newCall(bindSym"foo", sym)

doFoo()

Actual Output

..........................................................Traceback (most recent call last)
nim.nim(156)             nim
nim.nim(91)              handleCmdLine
main.nim(542)            mainCommand
main.nim(494)            compileToBackend
main.nim(217)            commandCompileToC
modules.nim(218)         compileProject
modules.nim(133)         compileModule
passes.nim(275)          processModule
passes.nim(102)          processTopLevelStmt
sem.nim(988)             myProcess
sem.nim(905)             semStmtAndGenerateGenerics nkStmtList 445754 sources/union/test.nim(9, 5)
semstmts.nim(3385)       semStmt
semexprs.nim(1443)       semExprNoType
semexprs.nim(3860)       semExpr nkStmtList 445754 sources/union/test.nim(9, 5)
semstmts.nim(3281)       semStmtList nkStmtList 445754 sources/union/test.nim(9, 5)
semexprs.nim(3704)       semExpr nkCall 445752 sources/union/test.nim(9, 5)
semexprs.nim(1419)       semDirectOp
semexprs.nim(1191)       afterCallActions
sem.nim(824)             semMacroExpr nkCall 445758 sources/union/test.nim(9, 5)
sem.nim(764)             semAfterMacroCall nkCall 445781 nimskull/0.1.0-dev.21458/lib/core/macros.nim(653, 21)
semexprs.nim(3704)       semExpr nkCall 445781 nimskull/0.1.0-dev.21458/lib/core/macros.nim(653, 21)
semexprs.nim(1415)       semDirectOp
semexprs.nim(1148)       semOverloadedCallAnalyseEffects nkCall 445781 nimskull/0.1.0-dev.21458/lib/core/macros.nim(653, 21)
semcall.nim(580)         semOverloadedCall nkCall 445781 nimskull/0.1.0-dev.21458/lib/core/macros.nim(653, 21)
semcall.nim(326)         resolveOverloads nkCall 445781 nimskull/0.1.0-dev.21458/lib/core/macros.nim(653, 21)
semcall.nim(73)          pickBestCandidate
sigmatch.nim(3302)       matches nkCall 445781 nimskull/0.1.0-dev.21458/lib/core/macros.nim(653, 21)
sigmatch.nim(3078)       matchesAux
sigmatch.nim(2639)       prepareOperand nkSym 445770 sources/union/test.nim(6, 19)
semexprs.nim(49)         semOperand
semexprs.nim(3615)       semExpr nkSym 445770 sources/union/test.nim(6, 19)
semexprs.nim(1655)       semSym
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

Expected Output

An error about the generated sym not having a type

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcompiler/semRelated to semantic-analysis system of the compiler

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions