summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorArne Döring <arne.doering@gmx.net>2019-11-22 19:57:43 +0100
committerMiran <narimiran@disroot.org>2019-11-22 19:57:43 +0100
commit2acf74d458accf65d969199a389c8dbc2eedab55 (patch)
tree086b8566b5c7af2ba509c2b24c8776c4e1482f5e
parentc85e266d1d6553fe14ecd28af7a58687672c859d (diff)
downloadNim-2acf74d458accf65d969199a389c8dbc2eedab55.tar.gz
delete list comprehension (#12392)
The `lc` macro is now part of `graveyard` repository.
-rw-r--r--changelog.md2
-rw-r--r--lib/pure/sugar.nim58
-rw-r--r--tests/compiles/trecursive_generic_in_compiles.nim8
3 files changed, 1 insertions, 67 deletions
diff --git a/changelog.md b/changelog.md
index a1b6b6166..d736400f9 100644
--- a/changelog.md
+++ b/changelog.md
@@ -16,7 +16,7 @@
 - `strutils.formatFloat` with `precision = 0` has the same behavior in all
   backends, and it is compatible with Python's behavior,
   e.g. `formatFloat(3.14159, precision = 0)` is now `3`, not `3.`.
-
+- Global variable `lc` has been removed from sugar.nim.
 
 ### Breaking changes in the compiler
 
diff --git a/lib/pure/sugar.nim b/lib/pure/sugar.nim
index c811f115c..af32e1546 100644
--- a/lib/pure/sugar.nim
+++ b/lib/pure/sugar.nim
@@ -122,64 +122,6 @@ macro `->`*(p, b: untyped): untyped =
 
   result = createProcType(p, b)
 
-type ListComprehension = object
-var lc* {.deprecated.}: ListComprehension
-
-template `|`*(lc: ListComprehension, comp: untyped): untyped {.deprecated.} = lc
-
-macro `[]`*(lc: ListComprehension, comp, typ: untyped): untyped {.deprecated.} =
-  ## List comprehension, returns a sequence. `comp` is the actual list
-  ## comprehension, for example ``x | (x <- 1..10, x mod 2 == 0)``. `typ` is
-  ## the type that will be stored inside the result seq.
-  ##
-  ## .. code-block:: nim
-  ##
-  ##   echo lc[x | (x <- 1..10, x mod 2 == 0), int]
-  ##
-  ##   const n = 20
-  ##   echo lc[(x,y,z) | (x <- 1..n, y <- x..n, z <- y..n, x*x + y*y == z*z),
-  ##           tuple[a,b,c: int]]
-  ## **Deprecated since version 0.19.9**
-
-  expectLen(comp, 3)
-  expectKind(comp, nnkInfix)
-  assert($comp[0] == "|")
-
-  result = newCall(
-    newDotExpr(
-      newIdentNode("result"),
-      newIdentNode("add")),
-    comp[1])
-
-  for i in countdown(comp[2].len-1, 0):
-    let x = comp[2][i]
-    expectMinLen(x, 1)
-    if x[0].kind == nnkIdent and $x[0].ident == "<-":
-      expectLen(x, 3)
-      result = newNimNode(nnkForStmt).add(x[1], x[2], result)
-    else:
-      result = newIfStmt((x, result))
-
-  result = newNimNode(nnkCall).add(
-    newNimNode(nnkPar).add(
-      newNimNode(nnkLambda).add(
-        newEmptyNode(),
-        newEmptyNode(),
-        newEmptyNode(),
-        newNimNode(nnkFormalParams).add(
-          newNimNode(nnkBracketExpr).add(
-            newIdentNode("seq"),
-            typ)),
-        newEmptyNode(),
-        newEmptyNode(),
-        newStmtList(
-          newAssignment(
-            newIdentNode("result"),
-            newNimNode(nnkPrefix).add(
-              newIdentNode("@"),
-              newNimNode(nnkBracket))),
-          result))))
-
 macro dump*(x: typed): untyped =
   ## Dumps the content of an expression, useful for debugging.
   ## It accepts any expression and prints a textual representation
diff --git a/tests/compiles/trecursive_generic_in_compiles.nim b/tests/compiles/trecursive_generic_in_compiles.nim
index c435ebaac..88d3faeed 100644
--- a/tests/compiles/trecursive_generic_in_compiles.nim
+++ b/tests/compiles/trecursive_generic_in_compiles.nim
@@ -92,11 +92,3 @@ proc foldLeft*[T,U](xs: List[T], z: U, f: (U, T) -> U): U =
   case xs.isEmpty
   of true: z
   else: foldLeft(xs.tail, f(z, xs.head), f)
-
-suite "unittest compilation error":
-
-  test "issue 3313":
-    let lst = lc[$x | (x <- 'a'..'z'), string].asList
-
-    let lstCopy = lst.dup
-    check: lstCopy == lst