Skip to content

sem: compiler crash on nested routine with typedesc parameter within generic parent #1553

@Luyten-Orion

Description

@Luyten-Orion

Specification

Defining a nested template or procedure that accepts a typedesc (not typedesc[T] where T is a type specifier), inside of a proc that has a generic parameter, triggers Fatal: Internal assert '' failed in semtypes.nim(2291, 15).

Example

proc test[T]() =
  template defaultVal(V: typedesc): V =
    when V is ref:
      new(V)
    else:
      default(V)

test[int]()

Actual Output

Fatal: Internal assert '' failed in semtypes.nim(2291, 15)
nim.nim(0)      nim
nim.nim(0)      handleCmdLine
main.nim(0)     mainCommand
main.nim(0)     compileToBackend
main.nim(0)     commandCompileToC
modules.nim(0)  compileProject
modules.nim(0)  compileModule
passes.nim(0)   processModule
passes.nim(0)   processTopLevelStmt
sem.nim(0)      myProcess
sem.nim(0)      semStmtAndGenerateGenerics
semstmts.nim(0) semStmt
semexprs.nim(0) semExprNoType
semexprs.nim(0) semExpr
semstmts.nim(0) semStmtList
semexprs.nim(0) semExpr
semexprs.nim(0) semIndirectOp
semexprs.nim(0) semDirectOp
semexprs.nim(0) semOverloadedCallAnalyseEffects
semcall.nim(0)  semOverloadedCall
semcall.nim(0)  semResolvedCall
seminst.nim(0)  generateInstance
seminst.nim(0)  instantiateBody
semexprs.nim(0) semProcBody
semexprs.nim(0) semExpr
semstmts.nim(0) semStmtList
semexprs.nim(0) semExpr
semstmts.nim(0) semRoutineDef
semtempl.nim(0) semTemplateDef
semstmts.nim(0) semRoutineParams
semstmts.nim(0) semParamList
semtypes.nim(0) semProcTypeNode
semtypes.nim(0) semTypeNode
msgs.nim(0)     doInternalAssert
msgs.nim(0)     handleReport
msgs.nim(0)     quit

Expected Output

No output.

Possible Solution

Additional Information

References

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