New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Concept/converter/generics-related compiler crash #7351

Closed
StasRuinsEverything opened this Issue Mar 17, 2018 · 0 comments

Comments

Projects
None yet
4 participants
@StasRuinsEverything
Copy link

StasRuinsEverything commented Mar 17, 2018

Apologies for the longish reproduction, but I couldn't simplify it further without missing the crash:

{.experimental.}

type
  Con1* = concept g, type T
      T.foo is float # commenting this line stops the crash

  Inter1*[T] = object # removing this type parameter stops the crash
    x: int

  Con2* = concept g, type T
    T.foo is float

  Inter2* = object
    x: int

  Con3* = concept g, type T
    T.foo is float

  Inter3* = object
    x: int


converter conToInter*[T: not typedesc and Con1](x: T): Inter1[RootRef] =
  Inter1[RootRef]()

converter conToInter*[T: not typedesc and Con2](x: T): Inter2 =
  Inter2()

converter conToInter*[T: not typedesc and Con3](x: T): Inter3 =
  Inter3()

template `.`*[T: pointer or RootRef](x: Inter1[T]; f: untyped): untyped =
  123

proc test1[T: Con1](s: seq[T]) =
  echo "okay"

proc test2(s: seq[Inter1[RootRef]]) =
  test1(s)

Note that besides the lines with the comments, getting rid of the stuff related to Con2/Inter2 or Con3/Inter3 (i.e. not necessarily both) avoids the crash, even though they're not being used anywhere. I assume this is because they participate in the resolution of the test1 call, but it's strange that keeping one of them is okay. Some kind of limit being hit?
Trying to compile it produces the following rather scary-looking stack trace:

nim.nim(121)             nim
nim.nim(77)              handleCmdLine
main.nim(173)            mainCommand
main.nim(77)             commandCompileToC
modules.nim(242)         compileProject
modules.nim(182)         compileModule
passes.nim(250)          processModule
passes.nim(139)          processTopLevelStmt
sem.nim(576)             myProcess
sem.nim(544)             semStmtAndGenerateGenerics
semstmts.nim(1920)       semStmt
semexprs.nim(793)        semExprNoType
semexprs.nim(2372)       semExpr
semstmts.nim(1669)       semProc
semstmts.nim(1593)       semProcAux
semexprs.nim(1438)       semProcBody
semexprs.nim(2354)       semExpr
semstmts.nim(1853)       semStmtList
semexprs.nim(2260)       semExpr
semexprs.nim(776)        semDirectOp
semexprs.nim(629)        semOverloadedCallAnalyseEffects
semcall.nim(428)         semOverloadedCall
semcall.nim(252)         resolveOverloads
semcall.nim(91)          pickBestCandidate
sigmatch.nim(2302)       matches
sigmatch.nim(2258)       matchesAux
sigmatch.nim(2005)       paramTypesMatch
sigmatch.nim(332)        paramTypesMatchAux
sigmatch.nim(332)        typeRelImpl
sigmatch.nim(1599)       typeRelImpl
sigmatch.nim(1544)       typeRelImpl
sigmatch.nim(735)        matchUserTypeClass
semexprs.nim(1737)       tryExpr
semexprs.nim(2354)       semExpr
semstmts.nim(1853)       semStmtList
semexprs.nim(2261)       semExpr
semexprs.nim(1827)       semMagic
semexprs.nim(320)        semIs
semexprs.nim(44)         semExprWithType
semexprs.nim(2215)       semExpr
semexprs.nim(2272)       semExpr
semexprs.nim(776)        semDirectOp
semexprs.nim(626)        semOverloadedCallAnalyseEffects
semcall.nim(428)         semOverloadedCall
semcall.nim(252)         resolveOverloads
semcall.nim(91)          pickBestCandidate
sigmatch.nim(2302)       matches
sigmatch.nim(2258)       matchesAux
sigmatch.nim(2005)       paramTypesMatch
sigmatch.nim(1984)       paramTypesMatchAux
sigmatch.nim(332)        userConvMatch
sigmatch.nim(1599)       typeRelImpl
sigmatch.nim(332)        typeRelImpl
sigmatch.nim(332)        typeRelImpl
sigmatch.nim(1702)       typeRelImpl
sigmatch.nim(1016)       typeRelImpl
sigmatch.nim(1022)       typeRelImpl
sigmatch.nim(1343)       typeRelImpl
sigmatch.nim(1399)       typeRelImpl
sigmatch.nim(957)        typeRelImpl
system.nim(3778)         failedAssertImpl
system.nim(3771)         raiseAssert
system.nim(2833)         sysFatal
Error: unhandled exception:
not (f == nil)  [AssertionError]

@Yardanico Yardanico added the Crash label Apr 12, 2018

@Araq Araq added this to the v1 milestone Jun 8, 2018

@Araq Araq closed this in ae901b3 Oct 2, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment