diff options
author | Araq <rumpf_a@web.de> | 2019-05-21 18:40:31 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-05-22 07:41:16 +0200 |
commit | 57bc8d73b439d974760937c6866d16afc742a25c (patch) | |
tree | a8342d681e1640917637f6a7ea74735143aad1b7 /compiler | |
parent | 1f7f0908ef0be0b0c16bdea96ff745e3815f2a40 (diff) | |
download | Nim-57bc8d73b439d974760937c6866d16afc742a25c.tar.gz |
fixes subtype relation regression
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/sigmatch.nim | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 109cb4de7..cd032c8a8 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -130,9 +130,8 @@ proc put(c: var TCandidate, key, val: PType) {.inline.} = echo "Putting ", typeToString(key), " ", typeToString(val), " and old is ", typeToString(old) if typeToString(old) == "seq[string]": writeStackTrace() - if typeToString(key) == "K": - echo "putting to K ", typeToString(val) - writeStackTrace() + if c.c.module.name.s == "temp3": + echo "binding ", key, " -> ", val idTablePut(c.bindings, key, val.skipIntLit) proc initCandidate*(ctx: PContext, c: var TCandidate, callee: PSym, @@ -1392,6 +1391,7 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, if roota.base == rootf.base: let nextFlags = flags + {trNoCovariance} var hasCovariance = false + # YYYY result = isEqual for i in 1 .. rootf.sonsLen-2: @@ -1437,7 +1437,8 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, let baseType = aAsObject.base if baseType != nil: c.inheritancePenalty += 1 - return typeRel(c, f, baseType) + let ret = typeRel(c, f, baseType) + return if ret == isEqual: isSubtype else: ret result = isNone else: @@ -1793,6 +1794,21 @@ proc typeRel(c: var TCandidate, f, aOrig: PType, else: internalError c.c.graph.config, " unknown type kind " & $f.kind +when false: + var nowDebug = false + var dbgCount = 0 + + proc typeRel(c: var TCandidate, f, aOrig: PType, + flags: TTypeRelFlags = {}): TTypeRelation = + if nowDebug: + echo f, " <- ", aOrig + inc dbgCount + if dbgCount == 2: + writeStackTrace() + result = typeRelImpl(c, f, aOrig, flags) + if nowDebug: + echo f, " <- ", aOrig, " res ", result + proc cmpTypes*(c: PContext, f, a: PType): TTypeRelation = var m: TCandidate initCandidate(c, m, f) |