From 1cc4d3f6220c5609e38258bd2c5a348e83106be4 Mon Sep 17 00:00:00 2001 From: metagn Date: Fri, 25 Aug 2023 22:08:47 +0300 Subject: fix generic param substitution in templates (#22535) * fix generic param substitution in templates fixes #13527, fixes #17240, fixes #6340, fixes #20033, fixes #19576, fixes #19076 * fix bare except in test, test updated packages in CI --- compiler/sem.nim | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'compiler/sem.nim') diff --git a/compiler/sem.nim b/compiler/sem.nim index f69e7a69d..653d83aaa 100644 --- a/compiler/sem.nim +++ b/compiler/sem.nim @@ -473,7 +473,13 @@ proc semAfterMacroCall(c: PContext, call, macroResult: PNode, # we now know the supplied arguments var paramTypes = initIdTable() for param, value in genericParamsInMacroCall(s, call): - idTablePut(paramTypes, param.typ, value.typ) + var givenType = value.typ + # the sym nodes used for the supplied generic arguments for + # templates and macros leave type nil so regular sem can handle it + # in this case, get the type directly from the sym + if givenType == nil and value.kind == nkSym and value.sym.typ != nil: + givenType = value.sym.typ + idTablePut(paramTypes, param.typ, givenType) retType = generateTypeInstance(c, paramTypes, macroResult.info, retType) -- cgit 1.4.1-2-gfad0