summary refs log tree commit diff stats
path: root/compiler/sem.nim
diff options
context:
space:
mode:
authorLemonBoy <LemonBoy@users.noreply.github.com>2018-06-27 21:43:08 +0200
committerAndreas Rumpf <rumpf_a@web.de>2018-06-27 21:43:07 +0200
commit52fc16d5d2f152df1cfc26ae1eb8df92f77ee7cb (patch)
treed2cbd72eecba7ee8b45944da2efa12fcf05ff895 /compiler/sem.nim
parent7f148838a461397f75853945e33eef29583dcc57 (diff)
downloadNim-52fc16d5d2f152df1cfc26ae1eb8df92f77ee7cb.tar.gz
Return an error symbol as macro output if needed (#8116)
Return an error symbol if the macro output has no type and a typedesc
is expected.

Fixes #7454
Diffstat (limited to 'compiler/sem.nim')
-rw-r--r--compiler/sem.nim7
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/sem.nim b/compiler/sem.nim
index 299286545..0adcccfbe 100644
--- a/compiler/sem.nim
+++ b/compiler/sem.nim
@@ -412,7 +412,12 @@ proc semAfterMacroCall(c: PContext, call, macroResult: PNode,
     of tyTypeDesc:
       if result.kind == nkStmtList: result.kind = nkStmtListType
       var typ = semTypeNode(c, result, nil)
-      result.typ = makeTypeDesc(c, typ)
+      if typ == nil:
+        localError(c.config, result.info, "expression has no type: " &
+                   renderTree(result, {renderNoComments}))
+        result = newSymNode(errorSym(c, result))
+      else:
+        result.typ = makeTypeDesc(c, typ)
       #result = symNodeFromType(c, typ, n.info)
     else:
       var retType = s.typ.sons[0]