implemented delegators and improved the error messages of unmatched type classes

This commit is contained in:
Zahary Karadjov 2013-08-26 21:53:56 +03:00
commit 28d9398de7
13 changed files with 130 additions and 93 deletions

View file

@ -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)