This commit is contained in:
Andreas Rumpf
2016-08-04 00:57:48 +02:00
parent 6d98c717de
commit 7ac0b20339
2 changed files with 25 additions and 0 deletions

View File

@@ -1310,6 +1310,13 @@ proc localConvMatch(c: PContext, m: var TCandidate, f, a: PType,
if r == isGeneric:
result.typ = getInstantiatedType(c, arg, m, base(f))
m.baseTypeMatch = true
# bug #4545: allow the call to go through a 'var T':
let vt = result.sons[0].typ.sons[1]
if vt.kind == tyVar:
let x = result.sons[1]
let va = newNodeIT(nkHiddenAddr, x.info, vt)
va.add x
result.sons[1] = va
proc incMatches(m: var TCandidate; r: TTypeRelation; convMatch = 1) =
case r

View File

@@ -0,0 +1,18 @@
# bug #4545
type SomeObject = object
a : int
type AbstractObject = object
objet: ptr SomeObject
proc convert(this: var SomeObject): AbstractObject =
AbstractObject(objet: this.addr)
proc varargProc(args: varargs[AbstractObject, convert]): int =
for arg in args:
result += arg.objet.a
var obj = SomeObject(a: 17)
discard varargProc(obj)