mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-04 20:17:42 +00:00
concepts: fixes the stack overflow that happens for #6691
This commit is contained in:
@@ -1057,9 +1057,10 @@ proc typeRelImpl(c: var TCandidate, f, aOrig: PType,
|
||||
else: isNone
|
||||
|
||||
of tyUserTypeClass, tyUserTypeClassInst:
|
||||
if c.c.matchedConcept != nil:
|
||||
if c.c.matchedConcept != nil and c.c.matchedConcept.depth <= 4:
|
||||
# consider this: 'var g: Node' *within* a concept where 'Node'
|
||||
# is a concept too (tgraph)
|
||||
inc c.c.matchedConcept.depth
|
||||
let x = typeRel(c, a, f, flags + {trDontBind})
|
||||
if x >= isGeneric:
|
||||
return isGeneric
|
||||
|
||||
13
tests/concepts/tinfrecursion.nim
Normal file
13
tests/concepts/tinfrecursion.nim
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
# bug #6691
|
||||
type
|
||||
ConceptA = concept c
|
||||
|
||||
ConceptB = concept c
|
||||
c.myProc(ConceptA)
|
||||
|
||||
Obj = object
|
||||
|
||||
proc myProc(obj: Obj, x: ConceptA) = discard
|
||||
|
||||
echo Obj is ConceptB
|
||||
Reference in New Issue
Block a user