summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rwxr-xr-xcompiler/sem.nim29
-rwxr-xr-xcompiler/semexprs.nim2
-rwxr-xr-xcompiler/seminst.nim7
3 files changed, 21 insertions, 17 deletions
diff --git a/compiler/sem.nim b/compiler/sem.nim
index 0f2627998..2c65f55a0 100755
--- a/compiler/sem.nim
+++ b/compiler/sem.nim
@@ -111,21 +111,24 @@ proc semAfterMacroCall(c: PContext, n: PNode, s: PSym): PNode =
     GlobalError(s.info, errTemplateInstantiationTooNested)
 
   result = n
-  case s.typ.sons[0].kind
-  of tyExpr:
-    # BUGFIX: we cannot expect a type here, because module aliases would not 
-    # work then (see the ``tmodulealias`` test)
-    # semExprWithType(c, result)
-    result = semExpr(c, result)
-  of tyStmt:
+  if s.typ.sons[0] == nil:
     result = semStmt(c, result)
-  of tyTypeDesc:
-    if n.kind == nkStmtList: result.kind = nkStmtListType
-    result.typ = semTypeNode(c, result, nil)
   else:
-    result = semExpr(c, result)
-    result = fitNode(c, s.typ.sons[0], result)
-    #GlobalError(s.info, errInvalidParamKindX, typeToString(s.typ.sons[0]))
+    case s.typ.sons[0].kind
+    of tyExpr:
+      # BUGFIX: we cannot expect a type here, because module aliases would not 
+      # work then (see the ``tmodulealias`` test)
+      # semExprWithType(c, result)
+      result = semExpr(c, result)
+    of tyStmt:
+      result = semStmt(c, result)
+    of tyTypeDesc:
+      if n.kind == nkStmtList: result.kind = nkStmtListType
+      result.typ = semTypeNode(c, result, nil)
+    else:
+      result = semExpr(c, result)
+      result = fitNode(c, s.typ.sons[0], result)
+      #GlobalError(s.info, errInvalidParamKindX, typeToString(s.typ.sons[0]))
   dec(evalTemplateCounter)
 
 proc semMacroExpr(c: PContext, n, nOrig: PNode, sym: PSym, 
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index 027cd0946..521de8c23 100755
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -707,7 +707,7 @@ proc semExprNoType(c: PContext, n: PNode): PNode =
     result = isCallExpr(n) and n.sons[0].kind == nkSym and 
              sfDiscardable in n.sons[0].sym.flags
   result = semExpr(c, n)
-  if result.typ != nil and result.typ.kind != tyStmt:
+  if result.typ != nil and result.typ.kind notin {tyStmt, tyEmpty}:
     if gCmd == cmdInteractive:
       result = buildEchoStmt(c, result)
     elif not ImplicitelyDiscardable(result) and result.typ.kind != tyError:
diff --git a/compiler/seminst.nim b/compiler/seminst.nim
index a03f62075..ffda48fba 100755
--- a/compiler/seminst.nim
+++ b/compiler/seminst.nim
@@ -74,7 +74,7 @@ proc instantiateBody(c: PContext, n: PNode, result: PSym) =
     # add it here, so that recursive generic procs are possible:
     addDecl(c, result)
     pushProcCon(c, result)
-    if result.kind in {skProc, skMethod, skConverter}: 
+    if result.kind in {skProc, skMethod, skConverter, skMacro}: 
       addResult(c, result.typ.sons[0], n.info, result.kind)
       addResultNode(c, n)
     var b = semStmtScope(c, n.sons[bodyPos])
@@ -184,8 +184,9 @@ proc generateInstance(c: PContext, fn: PSym, pt: TIdTable,
       pragma(c, result, n.sons[pragmasPos], allRoutinePragmas)
     if isNil(n.sons[bodyPos]):
       n.sons[bodyPos] = copyTree(fn.getBody)
-    instantiateBody(c, n, result)
-    sideEffectsCheck(c, result)
+    if fn.kind != skTemplate:
+      instantiateBody(c, n, result)
+      sideEffectsCheck(c, result)
   else:
     result = oldPrc
   popInfoContext()