summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rw-r--r--compiler/sem.nim8
-rw-r--r--compiler/semcall.nim7
2 files changed, 13 insertions, 2 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)
diff --git a/compiler/semcall.nim b/compiler/semcall.nim
index e7c9226dd..adb87b5b4 100644
--- a/compiler/semcall.nim
+++ b/compiler/semcall.nim
@@ -655,7 +655,12 @@ proc semResolvedCall(c: PContext, x: var TCandidate,
           else:
             x.call.add c.graph.emptyNode
         of skType:
-          x.call.add newSymNode(s, n.info)
+          var tn = newSymNode(s, n.info)
+          # this node will be used in template substitution,
+          # pretend this is an untyped node and let regular sem handle the type
+          # to prevent problems where a generic parameter is treated as a value
+          tn.typ = nil
+          x.call.add tn
         else:
           internalAssert c.config, false