some steps to improve the type mismatches with the new

generic instantiation logic
This commit is contained in:
Zahary Karadjov 2013-05-28 19:52:29 +03:00
commit 3e79e9f981
3 changed files with 27 additions and 10 deletions

View file

@ -180,15 +180,9 @@ proc argTypeToString(arg: PNode): string =
else:
result = arg.typ.typeToString
proc NotFoundError*(c: PContext, n: PNode) =
# Gives a detailed error message; this is separated from semOverloadedCall,
# as semOverlodedCall is already pretty slow (and we need this information
# only in case of an error).
if c.InCompilesContext > 0:
# fail fast:
GlobalError(n.info, errTypeMismatch, "")
var result = msgKindToString(errTypeMismatch)
for i in countup(1, sonsLen(n) - 1):
proc describeArgs*(c: PContext, n: PNode, startIdx = 1): string =
result = ""
for i in countup(startIdx, n.len - 1):
var arg = n.sons[i]
if n.sons[i].kind == nkExprEqExpr:
add(result, renderTree(n.sons[i].sons[0]))
@ -204,6 +198,16 @@ proc NotFoundError*(c: PContext, n: PNode) =
if arg.typ.kind == tyError: return
add(result, argTypeToString(arg))
if i != sonsLen(n) - 1: add(result, ", ")
proc NotFoundError*(c: PContext, n: PNode) =
# Gives a detailed error message; this is separated from semOverloadedCall,
# as semOverlodedCall is already pretty slow (and we need this information
# only in case of an error).
if c.InCompilesContext > 0:
# fail fast:
GlobalError(n.info, errTypeMismatch, "")
var result = msgKindToString(errTypeMismatch)
add(result, describeArgs(c, n))
add(result, ')')
var candidates = ""
var o: TOverloadIter