summary refs log tree commit diff stats
path: root/compiler/ccgexprs.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2013-05-06 18:30:54 +0200
committerAraq <rumpf_a@web.de>2013-05-06 18:30:54 +0200
commit6c0425d574bc45417e126bb2712fb42ddf9e553c (patch)
treebc1c175c9025425f5239ac8c32afe4b7600ecc73 /compiler/ccgexprs.nim
parent23bd3ccd8bc1b6aae931a3754ad478849c3be82d (diff)
downloadNim-6c0425d574bc45417e126bb2712fb42ddf9e553c.tar.gz
'result/return' triggers a void context
Diffstat (limited to 'compiler/ccgexprs.nim')
-rw-r--r--compiler/ccgexprs.nim16
1 files changed, 13 insertions, 3 deletions
diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim
index a50b39d47..2f7804384 100644
--- a/compiler/ccgexprs.nim
+++ b/compiler/ccgexprs.nim
@@ -1799,10 +1799,20 @@ proc expr(p: BProc, n: PNode, d: var TLoc) =
   of nkCall, nkHiddenCallConv, nkInfix, nkPrefix, nkPostfix, nkCommand,
      nkCallStrLit:
     genLineDir(p, n)
-    if n.sons[0].kind == nkSym and n.sons[0].sym.magic != mNone:
-      genMagicExpr(p, n, d, n.sons[0].sym.magic)
+    let op = n.sons[0]
+    if n.typ.isNil:
+      # discard the value:
+      var a: TLoc
+      if op.kind == nkSym and op.sym.magic != mNone:
+        genMagicExpr(p, n, a, op.sym.magic)
+      else:
+        genCall(p, n, a)
     else:
-      genCall(p, n, d)
+      # load it into 'd':
+      if op.kind == nkSym and op.sym.magic != mNone:
+        genMagicExpr(p, n, d, op.sym.magic)
+      else:
+        genCall(p, n, d)
   of nkCurly:
     if isDeepConstExpr(n) and n.len != 0:
       putIntoDest(p, d, n.typ, genSetNode(p, n))