diff --git a/compiler/sigmatch.nim b/compiler/sigmatch.nim index 90b4d6b1ce..612a98f431 100644 --- a/compiler/sigmatch.nim +++ b/compiler/sigmatch.nim @@ -1894,7 +1894,7 @@ proc implicitConv(kind: TNodeKind, f: PType, arg: PNode, m: TCandidate, else: result.typ = errorType(c) else: - result.typ = f.skipTypes({tySink}) + result.typ = f.skipTypes({tySink, tyVar}) if result.typ == nil: internalError(c.graph.config, arg.info, "implicitConv") result.add c.graph.emptyNode result.add arg @@ -2153,7 +2153,8 @@ proc paramTypesMatchAux(m: var TCandidate, f, a: PType, of isEqual: inc(m.exactMatches) result = arg - if skipTypes(f, abstractVar-{tyTypeDesc}).kind == tyTuple or + let ff = skipTypes(f, abstractVar-{tyTypeDesc}) + if ff.kind == tyTuple or (arg.typ != nil and skipTypes(arg.typ, abstractVar-{tyTypeDesc}).kind == tyTuple): result = implicitConv(nkHiddenSubConv, f, arg, m, c) of isNone: diff --git a/tests/template/t19149.nim b/tests/template/t19149.nim new file mode 100644 index 0000000000..631e8fc306 --- /dev/null +++ b/tests/template/t19149.nim @@ -0,0 +1,19 @@ +type Foo = tuple[active: bool, index: int] + + +var f: Foo + +# template result type during match stage +# f:var Foo +# a:Foo +# tyVar +# tyTuple +# after change to proc +# f:Foo +# a:Foo +# tyTuple +# tyTuple + +template cursor(): var Foo = f +discard cursor() +