summary refs log tree commit diff stats
path: root/compiler/semmagic.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2019-02-08 17:18:17 +0100
committerAndreas Rumpf <rumpf_a@web.de>2019-02-08 17:18:17 +0100
commit0841c64a3217594d0d260a0f24616b469447c1b9 (patch)
treed16995b64b4cd42b7e3d9adf94dd7f7ff57b600c /compiler/semmagic.nim
parentcb9110c43d4ae9c29a0a1e0d54f7735712d4ba62 (diff)
parent444f2231c9b48c34f9bec2ce6cfa3de5ae2560b1 (diff)
downloadNim-0841c64a3217594d0d260a0f24616b469447c1b9.tar.gz
Merge branch 'devel' into araq-quirky-exceptions
Diffstat (limited to 'compiler/semmagic.nim')
-rw-r--r--compiler/semmagic.nim12
1 files changed, 11 insertions, 1 deletions
diff --git a/compiler/semmagic.nim b/compiler/semmagic.nim
index 05c8b181c..6e5563d69 100644
--- a/compiler/semmagic.nim
+++ b/compiler/semmagic.nim
@@ -16,7 +16,12 @@ proc semAddr(c: PContext; n: PNode; isUnsafeAddr=false): PNode =
   if x.kind == nkSym:
     x.sym.flags.incl(sfAddrTaken)
   if isAssignable(c, x, isUnsafeAddr) notin {arLValue, arLocalLValue}:
-    localError(c.config, n.info, errExprHasNoAddress)
+    # Do not suggest the use of unsafeAddr if this expression already is a
+    # unsafeAddr
+    if isUnsafeAddr:
+      localError(c.config, n.info, errExprHasNoAddress)
+    else:
+      localError(c.config, n.info, errExprHasNoAddress & "; maybe use 'unsafeAddr'")
   result.add x
   result.typ = makePtrType(c, x.typ)
 
@@ -410,4 +415,9 @@ proc magicsAfterOverloadResolution(c: PContext, n: PNode,
       result = n
     else:
       result = plugin(c, n)
+  of mNewFinalize:
+    # Make sure the finalizer procedure refers to a procedure
+    if n[^1].kind == nkSym and n[^1].sym.kind notin {skProc, skFunc}:
+      localError(c.config, n.info, "finalizer must be a direct reference to a procedure")
+    result = n
   else: result = n