Skip to content

Commit 07959b7

Browse files
zerbinasaem
andauthored
sigmatch: fix missing conversion for varargs containers (nim-works#1627)
## Summary Fix an internal-only problem with `sigmatch` handling of named parameters in conjunction with `varargs`. ## Details Unlike for unnamed parameters, the implicit array construction created when using named parameters for passing a single value to a `varargs` parameter was not wrapped in a to-varargs conversion, nor was the type marked as being a varargs container (via the `tfVarargs` flag). This caused no downstream issues so far, as all three code generators handle the necessary run-time conversion themselves, but it's still incorrect. Co-authored-by: Saem Ghani <saemghani+github@gmail.com>
1 parent fe06e72 commit 07959b7

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

compiler/sem/sigmatch.nim

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2986,8 +2986,10 @@ proc matchesAux(c: PContext, n, nOrig: PNode, diags: DiagContext,
29862986
if m.baseTypeMatch or (arg.isError and container.isNil):
29872987
#assert(container.isNil())
29882988
container = newNodeIT(nkBracket, n[a].info, arrayConstr(c, arg))
2989+
container.typ.flags.incl tfVarargs
29892990
container.add arg
2990-
setSon(m.call, formal.position + 1, container)
2991+
setSon(m.call, formal.position + 1,
2992+
implicitConv(nkHiddenStdConv, formal.typ, container, m, c))
29912993

29922994
if f != formalLen - 1: # not the last formal param
29932995
container = nil # xxx: is this more vararg stuff?

0 commit comments

Comments
 (0)