From 57b8664a0c89788ea6ccdd8817905fff122a7c88 Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Wed, 10 Aug 2016 11:14:02 +0200 Subject: fixes #4589 --- compiler/sigmatch.nim | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'compiler/sigmatch.nim') diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 3918bb74b..ce4f893ea 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -985,11 +985,9 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation = of tyGenericBody: considerPreviousT: - let ff = lastSon(f) - var depth = 0 - if a.kind == tyGenericInst and (a.sons[0] == f): #or (ff != nil and ff.kind == tyObject and isGenericSubtype(a.sons[0], ff, depth))): - c.inheritancePenalty += depth + if a.kind == tyGenericInst and a.sons[0] == f: bindingRet isGeneric + let ff = lastSon(f) if ff != nil: result = typeRel(c, ff, a) @@ -1006,7 +1004,9 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation = for i in countup(1, sonsLen(f) - 1): if x.sons[i].kind == tyGenericParam: internalError("wrong instantiated type!") - elif typeRel(c, f.sons[i], x.sons[i]) <= isSubtype: return + elif typeRel(c, f.sons[i], x.sons[i]) <= isSubtype: + # Workaround for regression #4589 + if f.sons[i].kind != tyTypeDesc: return c.inheritancePenalty += depth result = isGeneric else: @@ -1024,7 +1024,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, doBind = true): TTypeRelation = # # we steal the generic parameters from the tyGenericBody: for i in countup(1, sonsLen(f) - 1): - var x = PType(idTableGet(c.bindings, genericBody.sons[i-1])) + let x = PType(idTableGet(c.bindings, genericBody.sons[i-1])) if x == nil: discard "maybe fine (for eg. a==tyNil)" elif x.kind in {tyGenericInvocation, tyGenericParam}: -- cgit 1.4.1-2-gfad0