summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2015-04-24 16:29:20 +0200
committerAraq <rumpf_a@web.de>2015-04-25 23:16:57 +0200
commit4d20aafb5eb0e193c031f52998d50fdf905ab7e8 (patch)
tree866c9c751606ae458df5c54b537012a0f1a8f1cb
parent47271b094c224ddd365d2f0c79249493af2ab084 (diff)
downloadNim-4d20aafb5eb0e193c031f52998d50fdf905ab7e8.tar.gz
fixes #2372
-rw-r--r--compiler/semexprs.nim2
-rw-r--r--tests/macros/treturnsempty.nim12
2 files changed, 13 insertions, 1 deletions
diff --git a/compiler/semexprs.nim b/compiler/semexprs.nim
index eb8d0c561..361608a5c 100644
--- a/compiler/semexprs.nim
+++ b/compiler/semexprs.nim
@@ -24,7 +24,7 @@ proc semFieldAccess(c: PContext, n: PNode, flags: TExprFlags = {}): PNode
 proc semOperand(c: PContext, n: PNode, flags: TExprFlags = {}): PNode =
   # same as 'semExprWithType' but doesn't check for proc vars
   result = semExpr(c, n, flags + {efOperand})
-  if result.kind == nkEmpty:
+  if result.kind == nkEmpty and result.typ.isNil:
     # do not produce another redundant error message:
     #raiseRecoverableError("")
     result = errorNode(c, n)
diff --git a/tests/macros/treturnsempty.nim b/tests/macros/treturnsempty.nim
new file mode 100644
index 000000000..7af26a747
--- /dev/null
+++ b/tests/macros/treturnsempty.nim
@@ -0,0 +1,12 @@
+discard """
+  errormsg: "type mismatch"
+  line: 11
+"""
+# bug #2372
+macro foo(dummy: int): stmt =
+  discard
+
+proc takeStr(s: string) = echo s
+
+takeStr foo(12)
+