From 2e8325a19ced18fd7284ec616529453e5915ccb4 Mon Sep 17 00:00:00 2001 From: konsumlamm <44230978+konsumlamm@users.noreply.github.com> Date: Fri, 5 Mar 2021 12:08:03 +0100 Subject: [PATCH] Remove support for named procs with sugar.=> (#17220) * Add docs & tests for named procs with sugar.=> * Remove support for named procs in sugar.=> * Resolve conflict * Fix test --- changelog.md | 3 +++ lib/pure/sugar.nim | 10 ---------- tests/macros/tclosuremacro.nim | 10 ++-------- 3 files changed, 5 insertions(+), 18 deletions(-) diff --git a/changelog.md b/changelog.md index 94f5f32537..3521904f67 100644 --- a/changelog.md +++ b/changelog.md @@ -194,6 +194,9 @@ provided by the operating system. - `system.addEscapedChar` now renders `\r` as `\r` instead of `\c`, to be compatible with most other languages. +- Removed support for named procs in `sugar.=>` + + ## Language changes - `nimscript` now handles `except Exception as e`. diff --git a/lib/pure/sugar.nim b/lib/pure/sugar.nim index 8d23696acc..aa1cc5fb80 100644 --- a/lib/pure/sugar.nim +++ b/lib/pure/sugar.nim @@ -87,16 +87,6 @@ macro `=>`*(p, b: untyped): untyped = checkPragma(p, pragma) # check again after -> transform - since (1, 3): - if p.kind in {nnkCall, nnkObjConstr}: - # foo(x, y) => x + y - kind = nnkProcDef - name = p[0] - let newP = newNimNode(nnkPar) - for i in 1.. int): (int) -> int = doAssert pass2((x, y) => x + y)(4) == 6 -fun(x, y: int) {.noSideEffect.} => x + y +const fun = (x, y: int) {.noSideEffect.} => x + y doAssert typeof(fun) is (proc (x, y: int): int {.nimcall.}) doAssert fun(3, 4) == 7 @@ -70,9 +68,7 @@ m: proc mystuff() = echo "yes" -sugarWithPragma() {.m.} => echo "sugarWithPragma called" - -typedParamAndPragma(x, y: int) {.used.} -> int => x + y +const typedParamAndPragma = (x, y: int) -> int => x + y doAssert typedParamAndPragma(1, 2) == 3 type @@ -82,5 +78,3 @@ type var myBot = Bot() myBot.call = () {.noSideEffect.} => "I'm a bot." doAssert myBot.call() == "I'm a bot." - -