diff options
author | metagn <metagngn@gmail.com> | 2023-08-25 22:08:47 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-25 21:08:47 +0200 |
commit | 1cc4d3f6220c5609e38258bd2c5a348e83106be4 (patch) | |
tree | 15ca4919b98ea45eaac5bf0bd33edfa55eeed4ae /compiler/sem.nim | |
parent | d677ed31e50a322851b476f20fd1719eb17cd426 (diff) | |
download | Nim-1cc4d3f6220c5609e38258bd2c5a348e83106be4.tar.gz |
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
Diffstat (limited to 'compiler/sem.nim')
-rw-r--r-- | compiler/sem.nim | 8 |
1 files changed, 7 insertions, 1 deletions
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) |