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

Methods break static[T] (internal error: nesting too deep) #5479

Closed
bluenote10 opened this Issue Mar 4, 2017 · 1 comment

Comments

Projects
None yet
5 participants
@bluenote10
Copy link
Contributor

bluenote10 commented Mar 4, 2017

It looks like it is not possible the have methods on types which use a static[] type parameter:

type
  Base[T: static[int]] = ref object of RootObj

method test[T](t: Base[T]) {.base.} =
  discard

let x = Base[1]()

Compilation takes a fairly long time and fails with internal error: nesting too deep. The same seems to work fine for a proc.

The problem also occurs when the base type itself does not use a static type parameter, but one if its subtypes does.

@genotrance

This comment has been minimized.

Copy link
Contributor

genotrance commented May 7, 2018

Still crashes with #head, full stacktrace below.

-------- SNIPPET --------
type
  Base[T: static[int]] = ref object of RootObj

method test[T](t: Base[T]) {.base.} =
  discard

let x = Base[1]()
-------------------------

-------- OUTPUT --------
Hint: used config file 'c:\users\gt\Desktop\DL\programming\nimdevel\config\nim.cfg' [Conf]
Hint: system [Processing]
Hint: temp [Processing]
temp.nim(7, 13) template/generic instantiation from here
temp.nim(7, 13) template/generic instantiation from here
temp.nim(4, 1) Error: internal error: nesting too deep
No stack traceback available
To create a stacktrace, rerun compilation with ./koch temp c <file>
------------------------

-------- NIMTEMP --------
Hint: used config file 'c:\users\gt\Desktop\DL\programming\nimdevel\config\nim.cfg' [Conf]
Hint: system [Processing]
Hint: temp [Processing]
Traceback (most recent call last)
nim.nim(113)             nim
nim.nim(77)              handleCmdLine
main.nim(173)            mainCommand
main.nim(77)             commandCompileToC
modules.nim(137)         compileProject
modules.nim(77)          compileModule
passes.nim(236)          processModule
passes.nim(125)          processTopLevelStmt
sem.nim(577)             myProcess
sem.nim(545)             semStmtAndGenerateGenerics
semstmts.nim(1862)       semStmt
semexprs.nim(803)        semExprNoType
semexprs.nim(2407)       semExpr
semstmts.nim(460)        semVarOrLet
semexprs.nim(44)         semExprWithType
semexprs.nim(2324)       semExpr
semexprs.nim(714)        semIndirectOp
semexprs.nim(2337)       semExpr
semexprs.nim(1314)       semArrayAccess
semexprs.nim(1269)       semSubscript
semtypes.nim(1453)       semTypeNode
semtypes.nim(1193)       semGeneric
seminst.nim(217)         instGenericContainer
semtypinst.nim(124)      replaceTypeVarsT
semtypinst.nim(452)      replaceTypeVarsTAux
semtypinst.nim(379)      handleGenericInvocation
sigmatch.nim(2373)       instTypeBoundOp
seminst.nim(324)         generateInstance
seminst.nim(249)         instantiateProcType
semtypinst.nim(124)      replaceTypeVarsT
semtypinst.nim(452)      replaceTypeVarsTAux
(1874 calls omitted) ...
seminst.nim(324)         generateInstance
seminst.nim(249)         instantiateProcType
semtypinst.nim(124)      replaceTypeVarsT
semtypinst.nim(452)      replaceTypeVarsTAux
semtypinst.nim(379)      handleGenericInvocation
sigmatch.nim(2373)       instTypeBoundOp
seminst.nim(324)         generateInstance
seminst.nim(249)         instantiateProcType
semtypinst.nim(124)      replaceTypeVarsT
semtypinst.nim(452)      replaceTypeVarsTAux
semtypinst.nim(379)      handleGenericInvocation
sigmatch.nim(2373)       instTypeBoundOp
seminst.nim(324)         generateInstance
seminst.nim(249)         instantiateProcType
semtypinst.nim(124)      replaceTypeVarsT
semtypinst.nim(452)      replaceTypeVarsTAux
semtypinst.nim(379)      handleGenericInvocation
sigmatch.nim(2373)       instTypeBoundOp
seminst.nim(324)         generateInstance
seminst.nim(249)         instantiateProcType
semtypinst.nim(124)      replaceTypeVarsT
semtypinst.nim(452)      replaceTypeVarsTAux
semtypinst.nim(379)      handleGenericInvocation
sigmatch.nim(2373)       instTypeBoundOp
seminst.nim(324)         generateInstance
seminst.nim(249)         instantiateProcType
semtypinst.nim(124)      replaceTypeVarsT
semtypinst.nim(452)      replaceTypeVarsTAux
semtypinst.nim(379)      handleGenericInvocation
sigmatch.nim(2373)       instTypeBoundOp
seminst.nim(324)         generateInstance
seminst.nim(249)         instantiateProcType
semtypinst.nim(124)      replaceTypeVarsT
semtypinst.nim(452)      replaceTypeVarsTAux
semtypinst.nim(379)      handleGenericInvocation
sigmatch.nim(2373)       instTypeBoundOp
seminst.nim(324)         generateInstance
seminst.nim(249)         instantiateProcType
semtypinst.nim(124)      replaceTypeVarsT
semtypinst.nim(452)      replaceTypeVarsTAux
semtypinst.nim(379)      handleGenericInvocation
sigmatch.nim(2373)       instTypeBoundOp
seminst.nim(324)         generateInstance
seminst.nim(249)         instantiateProcType
semtypinst.nim(124)      replaceTypeVarsT
semtypinst.nim(452)      replaceTypeVarsTAux
semtypinst.nim(379)      handleGenericInvocation
sigmatch.nim(2373)       instTypeBoundOp
seminst.nim(324)         generateInstance
seminst.nim(249)         instantiateProcType
semtypinst.nim(124)      replaceTypeVarsT
semtypinst.nim(452)      replaceTypeVarsTAux
semtypinst.nim(379)      handleGenericInvocation
sigmatch.nim(2373)       instTypeBoundOp
seminst.nim(324)         generateInstance
seminst.nim(249)         instantiateProcType
semtypinst.nim(124)      replaceTypeVarsT
semtypinst.nim(452)      replaceTypeVarsTAux
semtypinst.nim(379)      handleGenericInvocation
sigmatch.nim(2373)       instTypeBoundOp
seminst.nim(324)         generateInstance
seminst.nim(249)         instantiateProcType
semtypinst.nim(124)      replaceTypeVarsT
semtypinst.nim(452)      replaceTypeVarsTAux
semtypinst.nim(379)      handleGenericInvocation
sigmatch.nim(2373)       instTypeBoundOp
seminst.nim(324)         generateInstance
seminst.nim(249)         instantiateProcType
semtypinst.nim(124)      replaceTypeVarsT
semtypinst.nim(452)      replaceTypeVarsTAux
semtypinst.nim(379)      handleGenericInvocation
sigmatch.nim(2373)       instTypeBoundOp
seminst.nim(324)         generateInstance
seminst.nim(249)         instantiateProcType
semtypinst.nim(124)      replaceTypeVarsT
semtypinst.nim(452)      replaceTypeVarsTAux
semtypinst.nim(379)      handleGenericInvocation
sigmatch.nim(2373)       instTypeBoundOp
seminst.nim(324)         generateInstance
seminst.nim(249)         instantiateProcType
semtypinst.nim(124)      replaceTypeVarsT
semtypinst.nim(452)      replaceTypeVarsTAux
semtypinst.nim(379)      handleGenericInvocation
sigmatch.nim(2373)       instTypeBoundOp
seminst.nim(324)         generateInstance
seminst.nim(238)         instantiateProcType
semtypinst.nim           initLayeredTypeMap
assign.nim(230)          genericReset
assign.nim(217)          genericResetAux
assign.nim(215)          genericResetAux
assign.nim(230)          genericReset
assign.nim(217)          genericResetAux
assign.nim(215)          genericResetAux
assign.nim(228)          genericReset
gc.nim(284)              unsureAsgnRef
gc_common.nim            isOnStack
Stack overflow
-------------------------

-------- VERSION --------
Nim Compiler Version 0.18.1 [Windows: i386]
Compiled at 2018-05-06 23:11:03
Copyright (c) 2006-2018 by Andreas Rumpf

git hash: b13296533012426d386e986322009363af8a51bd
active boot switches: -d:release
-------------------------

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

@Araq Araq closed this in 7ac1e6e Oct 2, 2018

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