diff options
-rw-r--r-- | compiler/sem.nim | 7 | ||||
-rw-r--r-- | tests/macros/t7454.nim | 8 |
2 files changed, 14 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] diff --git a/tests/macros/t7454.nim b/tests/macros/t7454.nim new file mode 100644 index 000000000..e527de0c3 --- /dev/null +++ b/tests/macros/t7454.nim @@ -0,0 +1,8 @@ +discard """ +errormsg: "expression has no type:" +line: 8 +""" + +macro p(t: typedesc): typedesc = + discard +var a: p(int) |