summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
authorLemonBoy <LemonBoy@users.noreply.github.com>2019-01-21 19:12:17 +0100
committerMiran <narimiran@disroot.org>2019-01-21 19:12:17 +0100
commitee89ba6bdb664fe4972f2917499cff1afdac0bab (patch)
tree176b91e837ab7d2217713665c16fc28163017960 /compiler
parentae5d8fbd9d6b0c6469c2245da8a54d7b4c12f54f (diff)
downloadNim-ee89ba6bdb664fe4972f2917499cff1afdac0bab.tar.gz
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
Diffstat (limited to 'compiler')
-rw-r--r--compiler/sigmatch.nim5
1 files changed, 3 insertions, 2 deletions
diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim
index 9aae254f3..e08559db6 100644
--- a/compiler/sigmatch.nim
+++ b/compiler/sigmatch.nim
@@ -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)