fixes #4766
This commit is contained in:
parent
dc5851e873
commit
9c3cba1c22
2 changed files with 21 additions and 1 deletions
|
|
@ -326,7 +326,8 @@ proc generateInstance(c: PContext, fn: PSym, pt: TIdTable,
|
||||||
# no need to instantiate generic templates/macros:
|
# no need to instantiate generic templates/macros:
|
||||||
internalAssert c.config, fn.kind notin {skMacro, skTemplate}
|
internalAssert c.config, fn.kind notin {skMacro, skTemplate}
|
||||||
# generates an instantiated proc
|
# generates an instantiated proc
|
||||||
if c.instCounter > 1000: internalError(c.config, fn.ast.info, "nesting too deep")
|
if c.instCounter > 50:
|
||||||
|
globalError(c.config, info, "generic instantiation too nested")
|
||||||
inc(c.instCounter)
|
inc(c.instCounter)
|
||||||
# careful! we copy the whole AST including the possibly nil body!
|
# careful! we copy the whole AST including the possibly nil body!
|
||||||
var n = copyTree(fn.ast)
|
var n = copyTree(fn.ast)
|
||||||
|
|
|
||||||
19
tests/errmsgs/tnested_generic_instantiation.nim
Normal file
19
tests/errmsgs/tnested_generic_instantiation.nim
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
discard """
|
||||||
|
errormsg: "generic instantiation too nested"
|
||||||
|
file: "system.nim"
|
||||||
|
"""
|
||||||
|
|
||||||
|
# bug #4766
|
||||||
|
|
||||||
|
type
|
||||||
|
Plain = ref object
|
||||||
|
discard
|
||||||
|
|
||||||
|
Wrapped[T] = object
|
||||||
|
value: T
|
||||||
|
|
||||||
|
converter toWrapped[T](value: T): Wrapped[T] =
|
||||||
|
Wrapped[T](value: value)
|
||||||
|
|
||||||
|
let result = Plain()
|
||||||
|
discard $result
|
||||||
Loading…
Add table
Add a link
Reference in a new issue