summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorkonsumlamm <44230978+konsumlamm@users.noreply.github.com>2021-03-05 12:08:03 +0100
committerGitHub <noreply@github.com>2021-03-05 12:08:03 +0100
commit2e8325a19ced18fd7284ec616529453e5915ccb4 (patch)
tree05c050f5fb840db60766ec655bf770b5daa41d68
parent8f1fa3e5b014c4301477f2f1872afde0640906b3 (diff)
downloadNim-2e8325a19ced18fd7284ec616529453e5915ccb4.tar.gz
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
-rw-r--r--changelog.md3
-rw-r--r--lib/pure/sugar.nim10
-rw-r--r--tests/macros/tclosuremacro.nim10
3 files changed, 5 insertions, 18 deletions
diff --git a/changelog.md b/changelog.md
index 94f5f3253..3521904f6 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 8d23696ac..aa1cc5fb8 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..<p.len:
-        newP.add(p[i])
-      p = newP
-
   case p.kind
   of nnkPar, nnkTupleConstr:
     var untypedBeforeColon = 0
diff --git a/tests/macros/tclosuremacro.nim b/tests/macros/tclosuremacro.nim
index 2a7847b9e..44c2411a5 100644
--- a/tests/macros/tclosuremacro.nim
+++ b/tests/macros/tclosuremacro.nim
@@ -5,8 +5,6 @@ calling mystuff
 yes
 calling mystuff
 yes
-calling sugarWithPragma
-sugarWithPragma called
 '''
 """
 
@@ -40,7 +38,7 @@ proc pass2(f: (int, int) -> 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."
-
-
> 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327