add a useful helper for debugging typeRel problems
This commit is contained in:
parent
268b918150
commit
dea6d8dd94
1 changed files with 26 additions and 4 deletions
|
|
@ -302,9 +302,31 @@ proc describeArgs*(c: PContext, n: PNode, startIdx = 1;
|
||||||
add(result, argTypeToString(arg, prefer))
|
add(result, argTypeToString(arg, prefer))
|
||||||
if i != sonsLen(n) - 1: add(result, ", ")
|
if i != sonsLen(n) - 1: add(result, ", ")
|
||||||
|
|
||||||
proc typeRel*(c: var TCandidate, f, aOrig: PType,
|
proc typeRelImpl*(c: var TCandidate, f, aOrig: PType,
|
||||||
flags: TTypeRelFlags = {}): TTypeRelation
|
flags: TTypeRelFlags = {}): TTypeRelation
|
||||||
|
|
||||||
|
var nextTypeRel = 0
|
||||||
|
|
||||||
|
template typeRel*(c: var TCandidate, f, aOrig: PType,
|
||||||
|
flags: TTypeRelFlags = {}): TTypeRelation =
|
||||||
|
const traceTypeRel = false
|
||||||
|
|
||||||
|
when traceTypeRel:
|
||||||
|
var enteringAt = nextTypeRel
|
||||||
|
if mdbg:
|
||||||
|
inc nextTypeRel
|
||||||
|
echo "----- TYPE REL ", enteringAt
|
||||||
|
debug f
|
||||||
|
debug aOrig
|
||||||
|
|
||||||
|
let r = typeRelImpl(c, f, aOrig, flags)
|
||||||
|
|
||||||
|
when traceTypeRel:
|
||||||
|
if enteringAt != nextTypeRel:
|
||||||
|
echo "----- TYPE REL ", enteringAt, " RESULT: ", r
|
||||||
|
|
||||||
|
r
|
||||||
|
|
||||||
proc concreteType(c: TCandidate, t: PType): PType =
|
proc concreteType(c: TCandidate, t: PType): PType =
|
||||||
case t.kind
|
case t.kind
|
||||||
of tyNil:
|
of tyNil:
|
||||||
|
|
@ -871,7 +893,7 @@ proc isCovariantPtr(c: var TCandidate, f, a: PType): bool =
|
||||||
else:
|
else:
|
||||||
return false
|
return false
|
||||||
|
|
||||||
proc typeRel(c: var TCandidate, f, aOrig: PType,
|
proc typeRelImpl(c: var TCandidate, f, aOrig: PType,
|
||||||
flags: TTypeRelFlags = {}): TTypeRelation =
|
flags: TTypeRelFlags = {}): TTypeRelation =
|
||||||
# typeRel can be used to establish various relationships between types:
|
# typeRel can be used to establish various relationships between types:
|
||||||
#
|
#
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue