bugfix: type converter that converts to bool in 'if' context

This commit is contained in:
Araq 2011-03-25 00:47:03 +01:00
commit 032599c156
11 changed files with 77 additions and 25 deletions

View file

@ -461,6 +461,7 @@ proc userConvMatch(c: PContext, m: var TCandidate, f, a: PType,
var dest = c.converters[i].typ.sons[0]
if (typeRel(m.bindings, f, dest) == isEqual) and
(typeRel(m.bindings, src, a) == isEqual):
markUsed(arg, c.converters[i])
var s = newSymNode(c.converters[i])
s.typ = c.converters[i].typ
s.info = arg.info
@ -564,6 +565,11 @@ proc IndexTypesMatch*(c: PContext, f, a: PType, arg: PNode): PNode =
initCandidate(m, f)
result = paramTypesMatch(c, m, f, a, arg)
proc ConvertTo*(c: PContext, f: PType, n: PNode): PNode =
var m: TCandidate
initCandidate(m, f)
result = paramTypesMatch(c, m, f, n.typ, n)
proc argtypeMatches*(c: PContext, f, a: PType): bool =
var m: TCandidate
initCandidate(m, f)