Fix subtype conversion w/ varargs arguments (#10402)
The type matching is done on the `T` of the `varargs[T]` so the conversion must be performed to `T` and not to the whole type. This problem is only noticeable with the cpp backend since C doesn't give a damn shit about your fucking (wrong) types. Fixes #9845
This commit is contained in:
parent
ae5d8fbd9d
commit
ee89ba6bdb
5 changed files with 7 additions and 2 deletions
|
|
@ -2071,6 +2071,7 @@ proc paramTypesMatchAux(m: var TCandidate, f, a: PType,
|
|||
# constructor in a call:
|
||||
if result == nil and f.kind == tyVarargs:
|
||||
if f.n != nil:
|
||||
# Forward to the varargs converter
|
||||
result = localConvMatch(c, m, f, a, arg)
|
||||
else:
|
||||
r = typeRel(m, base(f), a)
|
||||
|
|
@ -2083,10 +2084,10 @@ proc paramTypesMatchAux(m: var TCandidate, f, a: PType,
|
|||
# bug #4799, varargs accepting subtype relation object
|
||||
elif r == isSubtype:
|
||||
inc(m.subtypeMatches)
|
||||
if f.kind == tyTypeDesc:
|
||||
if base(f).kind == tyTypeDesc:
|
||||
result = arg
|
||||
else:
|
||||
result = implicitConv(nkHiddenSubConv, f, arg, m, c)
|
||||
result = implicitConv(nkHiddenSubConv, base(f), arg, m, c)
|
||||
m.baseTypeMatch = true
|
||||
else:
|
||||
result = userConvMatch(c, m, base(f), a, arg)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue