summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rw-r--r--compiler/evaltempl.nim12
-rw-r--r--compiler/vm.nim9
-rw-r--r--compiler/vmgen.nim6
3 files changed, 21 insertions, 6 deletions
diff --git a/compiler/evaltempl.nim b/compiler/evaltempl.nim
index 015c14ab5..82c4e8f57 100644
--- a/compiler/evaltempl.nim
+++ b/compiler/evaltempl.nim
@@ -66,7 +66,16 @@ proc evalTemplateArgs(n: PNode, s: PSym): PNode =
     else: 0
 
   var
-    genericParams = s.ast[genericParamsPos].len
+    # XXX: Since immediate templates are not subjected to the
+    # standard sigmatching algorithm, they will have a number
+    # of deficiencies when it comes to generic params:
+    # Type dependencies between the parameters won't be honoured
+    # and the bound generic symbols won't be resolvable within
+    # their bodies. We could try to fix this, but it may be
+    # wiser to just deprecate immediate templates and macros
+    # now that we have working untyped parameters.
+    genericParams = if sfImmediate in s.flags: 0
+                    else: s.ast[genericParamsPos].len
     expectedRegularParams = <s.typ.len
     givenRegularParams = totalParams - genericParams
 
@@ -81,6 +90,7 @@ proc evalTemplateArgs(n: PNode, s: PSym): PNode =
   # not supplied by the user
   for i in givenRegularParams+1 .. expectedRegularParams:
     let default = s.typ.n.sons[i].sym.ast
+    internalAssert default != nil
     if default.kind == nkEmpty:
       localError(n.info, errWrongNumberOfArguments)
       addSon(result, ast.emptyNode)
diff --git a/compiler/vm.nim b/compiler/vm.nim
index fc63da1d4..a51087aa6 100644
--- a/compiler/vm.nim
+++ b/compiler/vm.nim
@@ -1521,10 +1521,11 @@ proc evalMacroCall*(module: PSym, n, nOrig: PNode, sym: PSym): PNode =
   for i in 1.. <sym.typ.len:
     tos.slots[i] = setupMacroParam(n.sons[i], sym.typ.sons[i])
 
-  let gp = sym.ast[genericParamsPos]
-  for i in 0 .. <gp.len:
-    let idx = sym.typ.len + i
-    tos.slots[idx] = setupMacroParam(n.sons[idx], gp[i].sym.typ)
+  if sfImmediate notin sym.flags:
+    let gp = sym.ast[genericParamsPos]
+    for i in 0 .. <gp.len:
+      let idx = sym.typ.len + i
+      tos.slots[idx] = setupMacroParam(n.sons[idx], gp[i].sym.typ)
 
   # temporary storage:
   #for i in L .. <maxSlots: tos.slots[i] = newNode(nkEmpty)
diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim
index 3f4ee8000..c75027e16 100644
--- a/compiler/vmgen.nim
+++ b/compiler/vmgen.nim
@@ -1845,9 +1845,13 @@ proc genProc(c: PCtx; s: PSym): int =
     c.prc = p
     # iterate over the parameters and allocate space for them:
     genParams(c, s.typ.n)
+    
     # allocate additional space for any generically bound parameters
-    if s.kind == skMacro and s.ast[genericParamsPos].kind != nkEmpty:
+    if s.kind == skMacro and
+       sfImmediate notin s.flags and
+       s.ast[genericParamsPos].kind != nkEmpty:
       genGenericParams(c, s.ast[genericParamsPos])
+    
     if tfCapturesEnv in s.typ.flags:
       #let env = s.ast.sons[paramsPos].lastSon.sym
       #assert env.position == 2