summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2017-10-19 12:59:01 +0200
committerAndreas Rumpf <rumpf_a@web.de>2017-10-19 13:29:11 +0200
commit0a3efccb55602aed39643e908b293ac0b617e3fe (patch)
treeb2ff3f49b614c67d346a3aac4e0a0da7af4e7857
parent9911d375b3877b8feb92cee680be34f73451d145 (diff)
downloadNim-0a3efccb55602aed39643e908b293ac0b617e3fe.tar.gz
preparations for another bugfix
-rw-r--r--compiler/semcall.nim4
-rw-r--r--compiler/sigmatch.nim13
2 files changed, 16 insertions, 1 deletions
diff --git a/compiler/semcall.nim b/compiler/semcall.nim
index 9492e63f4..2cc2cf205 100644
--- a/compiler/semcall.nim
+++ b/compiler/semcall.nim
@@ -90,6 +90,10 @@ proc pickBestCandidate(c: PContext, headSymbol: PNode,
     if c.currentScope.symbols.counter == counterInitial or syms != nil:
       matches(c, n, orig, z)
       if z.state == csMatch:
+        #if sym.name.s == "==" and (n.info ?? "temp3"):
+        #  echo typeToString(sym.typ)
+        #  writeMatches(z)
+
         # little hack so that iterators are preferred over everything else:
         if sym.kind == skIterator: inc(z.exactMatches, 200)
         case best.state
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim
index 50d4178b6..25981b826 100644
--- a/compiler/sigmatch.nim
+++ b/compiler/sigmatch.nim
@@ -224,7 +224,8 @@ proc complexDisambiguation(a, b: PType): int =
     let x = a.sons[i].sumGeneric
     let y = b.sons[i].sumGeneric
     #if ggDebug:
-    #  echo "came her ", typeToString(a.sons[i]), " ", typeToString(b.sons[i])
+    #echo "came herA ", typeToString(a.sons[i]), " ", x
+    #echo "came herB ", typeToString(b.sons[i]), " ", y
     if x != y:
       if winner == 0:
         if x > y: winner = 1
@@ -1550,11 +1551,21 @@ proc typeRelImpl(c: var TCandidate, f, aOrig: PType,
           result = isNone
       else:
         if f.sonsLen > 0 and f.sons[0].kind != tyNone:
+          when false:
+            let oldInheritancePenalty = c.inheritancePenalty
           result = typeRel(c, f.lastSon, a, flags + {trDontBind})
           if doBind and result notin {isNone, isGeneric}:
             let concrete = concreteType(c, a)
             if concrete == nil: return isNone
             put(c, f, concrete)
+          when false:
+            # bug #6526
+            if result in {isEqual, isSubtype}:
+              # 'T: Class' is a *better* match than just 'T'
+              # but 'T: Subclass' is even better:
+              c.inheritancePenalty = oldInheritancePenalty - c.inheritancePenalty -
+                                    100 * ord(result == isEqual)
+              result = isGeneric
         else:
           result = isGeneric