summary refs log tree commit diff stats
path: root/compiler/semstmts.nim
diff options
context:
space:
mode:
authorZahary Karadjov <zahary@gmail.com>2013-08-26 21:53:56 +0300
committerZahary Karadjov <zahary@gmail.com>2013-08-26 23:29:24 +0300
commit28d9398de7f70560254f120ae522e0a4df81576b (patch)
tree3e41d2e13f40e45a5bbd1feb5fb258c797ea2aec /compiler/semstmts.nim
parent89086a8e19292ad986baa808ff42ccad32bf2636 (diff)
downloadNim-28d9398de7f70560254f120ae522e0a4df81576b.tar.gz
implemented delegators and improved the error messages of unmatched type classes
Diffstat (limited to 'compiler/semstmts.nim')
-rw-r--r--compiler/semstmts.nim9
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim
index 3b83290ea..022d412ce 100644
--- a/compiler/semstmts.nim
+++ b/compiler/semstmts.nim
@@ -835,7 +835,14 @@ proc semProcAnnotation(c: PContext, prc: PNode): PNode =
     var it = n.sons[i]
     var key = if it.kind == nkExprColonExpr: it.sons[0] else: it
     let m = lookupMacro(c, key)
-    if m == nil: continue
+    if m == nil:
+      if key.kind == nkIdent and key.ident.id == ord(wDelegator):
+        if considerAcc(prc.sons[namePos]).s == "()":
+          prc.sons[namePos] = newIdentNode(idDelegator, prc.info)
+          prc.sons[pragmasPos] = copyExcept(n, i)
+        else:
+          LocalError(prc.info, errOnlyACallOpCanBeDelegator)
+      continue
     # we transform ``proc p {.m, rest.}`` into ``m(do: proc p {.rest.})`` and
     # let the semantic checker deal with it:
     var x = newNodeI(nkCall, n.info)