diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pure/sugar.nim | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/lib/pure/sugar.nim b/lib/pure/sugar.nim index d9c98c360..047104972 100644 --- a/lib/pure/sugar.nim +++ b/lib/pure/sugar.nim @@ -17,10 +17,7 @@ proc checkPragma(ex, prag: var NimNode) = since (1, 3): if ex.kind == nnkPragmaExpr: prag = ex[1] - if ex[0].kind == nnkPar and ex[0].len == 1: - ex = ex[0][0] - else: - ex = ex[0] + ex = ex[0] proc createProcType(p, b: NimNode): NimNode {.compileTime.} = result = newNimNode(nnkProcTy) @@ -66,12 +63,12 @@ macro `=>`*(p, b: untyped): untyped = type Bot = object - call: proc (): string {.nosideEffect.} + call: proc (name: string): string {.noSideEffect.} var myBot = Bot() - myBot.call = () {.nosideEffect.} => "I'm a bot." - doAssert myBot.call() == "I'm a bot." + myBot.call = (name: string) {.noSideEffect.} => "Hello " & name & ", I'm a bot." + doAssert myBot.call("John") == "Hello John, I'm a bot." var params = @[ident"auto"] @@ -89,7 +86,7 @@ macro `=>`*(p, b: untyped): untyped = checkPragma(p, pragma) # check again after -> transform since (1, 3): - if p.kind == nnkCall: + if p.kind in {nnkCall, nnkObjConstr}: # foo(x, y) => x + y kind = nnkProcDef name = p[0] @@ -129,7 +126,7 @@ macro `=>`*(p, b: untyped): untyped = error("Expected proc type (->) got (" & c[0].strVal & ").", c) break else: - error("Incorrect procedure parameter list.", c) + error("Incorrect procedure parameter.", c) params.add(identDefs) of nnkIdent: var identDefs = newNimNode(nnkIdentDefs) |