mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-29 09:24:36 +00:00
add a useful helper for debugging typeRel problems
This commit is contained in:
committed by
Andreas Rumpf
parent
268b918150
commit
dea6d8dd94
@@ -302,8 +302,30 @@ proc describeArgs*(c: PContext, n: PNode, startIdx = 1;
|
||||
add(result, argTypeToString(arg, prefer))
|
||||
if i != sonsLen(n) - 1: add(result, ", ")
|
||||
|
||||
proc typeRel*(c: var TCandidate, f, aOrig: PType,
|
||||
flags: TTypeRelFlags = {}): TTypeRelation
|
||||
proc typeRelImpl*(c: var TCandidate, f, aOrig: PType,
|
||||
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 =
|
||||
case t.kind
|
||||
@@ -871,8 +893,8 @@ proc isCovariantPtr(c: var TCandidate, f, a: PType): bool =
|
||||
else:
|
||||
return false
|
||||
|
||||
proc typeRel(c: var TCandidate, f, aOrig: PType,
|
||||
flags: TTypeRelFlags = {}): TTypeRelation =
|
||||
proc typeRelImpl(c: var TCandidate, f, aOrig: PType,
|
||||
flags: TTypeRelFlags = {}): TTypeRelation =
|
||||
# typeRel can be used to establish various relationships between types:
|
||||
#
|
||||
# 1) When used with concrete types, it will check for type equivalence
|
||||
|
||||
Reference in New Issue
Block a user