diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2017-11-05 21:31:02 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-11-05 21:31:02 +0100 |
commit | 9e4e1949e8e599bcfa560178243aabaf4b1bb68b (patch) | |
tree | 9beef3d83dd42d131200fffbf8322a692fc4291b | |
parent | 4e4d466d060f9b55cb2adb3ad02e212281df4962 (diff) | |
download | Nim-9e4e1949e8e599bcfa560178243aabaf4b1bb68b.tar.gz |
concepts: fixes the stack overflow that happens for #6691
-rw-r--r-- | compiler/sigmatch.nim | 3 | ||||
-rw-r--r-- | tests/concepts/tinfrecursion.nim | 13 |
2 files changed, 15 insertions, 1 deletions
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 231dd80f4..97b18306b 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -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 diff --git a/tests/concepts/tinfrecursion.nim b/tests/concepts/tinfrecursion.nim new file mode 100644 index 000000000..60db410de --- /dev/null +++ b/tests/concepts/tinfrecursion.nim @@ -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 |