From 9465b5db443b98d7ac2c1683e986716fb9a9290f Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Tue, 14 Jul 2020 11:44:56 -0300 Subject: [PATCH] Clean up macros (#14959) --- changelog.md | 2 +- examples/talk/formatoptimizer.nim | 2 +- lib/core/macros.nim | 34 ----------------------------- lib/pure/unittest.nim | 2 +- testament/important_packages.nim | 2 +- tests/macros/tmemit.nim | 3 --- tests/showoff/tformatopt.nim | 2 +- tests/usingstmt/tusingstatement.nim | 2 +- 8 files changed, 6 insertions(+), 43 deletions(-) diff --git a/changelog.md b/changelog.md index 36582eee2..e30e9038b 100644 --- a/changelog.md +++ b/changelog.md @@ -139,7 +139,7 @@ - Tables, HashSets, SharedTables and deques don't require anymore that the passed initial size must be a power of two - this is done internally. Proc `rightSize` for Tables and HashSets is deprecated, as it is not needed anymore. - +- Removed deprecated symbols from `macros` module, deprecated as far back as `0.15`. ## Language changes diff --git a/examples/talk/formatoptimizer.nim b/examples/talk/formatoptimizer.nim index 104214e19..6e3d0c2c3 100644 --- a/examples/talk/formatoptimizer.nim +++ b/examples/talk/formatoptimizer.nim @@ -33,7 +33,7 @@ macro optFormat{`%`(f, a)}(f: string{lit}, a: openArray[string]): untyped = #newCall("&") let f = f.strVal formatImpl(newLit) - result = nestList(!"&", result) + result = nestList(newIdentNode("&"), result) template optAdd1{x = y; add(x, z)}(x, y, z: string) = x = y & z diff --git a/lib/core/macros.nim b/lib/core/macros.nim index 838707280..7b03d4e4d 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -140,10 +140,6 @@ const {.push warnings: off.} -proc `!`*(s: string): NimIdent {.magic: "StrToIdent", noSideEffect, deprecated: - "Deprecated since version 0.18.0: Use 'ident' or 'newIdentNode' instead.".} - ## Constructs an identifier from the string `s`. - proc toNimIdent*(s: string): NimIdent {.magic: "StrToIdent", noSideEffect, deprecated: "Deprecated since version 0.18.0: Use 'ident' or 'newIdentNode' instead.".} ## Constructs an identifier from the string `s`. @@ -393,13 +389,6 @@ proc `ident=`*(n: NimNode, val: NimIdent) {.magic: "NSetIdent", noSideEffect, de {.pop.} -#proc `typ=`*(n: NimNode, typ: typedesc) {.magic: "NSetType".} -# this is not sound! Unfortunately forbidding 'typ=' is not enough, as you -# can easily do: -# let bracket = semCheck([1, 2]) -# let fake = semCheck(2.0) -# bracket[0] = fake # constructs a mixed array with ints and floats! - proc `strVal=`*(n: NimNode, val: string) {.magic: "NSetStrVal", noSideEffect.} ## Sets the string value of a string literal or comment. ## Setting `strVal` is disallowed for `nnkIdent` and `nnkSym` nodes; a new node @@ -830,14 +819,6 @@ proc nestList*(op: NimNode; pack: NimNode; init: NimNode): NimNode {.compileTime for i in countdown(pack.len - 1, 0): result = newCall(op, pack[i], result) -{.push warnings: off.} - -proc nestList*(theProc: NimIdent, x: NimNode): NimNode {.compileTime, deprecated: - "Deprecated since v0.18.1; use one of 'nestList(NimNode, ...)' instead.".} = - nestList(newIdentNode(theProc), x) - -{.pop.} - proc treeTraverse(n: NimNode; res: var string; level = 0; isLisp = false, indented = false) {.benign.} = if level > 0: if indented: @@ -1628,21 +1609,6 @@ macro getCustomPragmaVal*(n: typed, cp: typed{nkSym}): untyped = if result.kind == nnkEmpty: error(n.repr & " doesn't have a pragma named " & cp.repr()) # returning an empty node results in most cases in a cryptic error, - -when not defined(booting): - template emit*(e: static[string]): untyped {.deprecated.} = - ## Accepts a single string argument and treats it as nim code - ## that should be inserted verbatim in the program - ## Example: - ## - ## .. code-block:: nim - ## emit("echo " & '"' & "hello world".toUpper & '"') - ## - ## Deprecated since version 0.15 since it's so rarely useful. - macro payload: untyped {.gensym.} = - result = parseStmt(e) - payload() - macro unpackVarargs*(callee: untyped; args: varargs[untyped]): untyped = result = newCall(callee) for i in 0 ..< args.len: diff --git a/lib/pure/unittest.nim b/lib/pure/unittest.nim index f3d920d0e..98be959e3 100644 --- a/lib/pure/unittest.nim +++ b/lib/pure/unittest.nim @@ -678,7 +678,7 @@ macro check*(conditions: untyped): untyped = result = newNimNode(nnkStmtList) for node in checked: if node.kind != nnkCommentStmt: - result.add(newCall(!"check", node)) + result.add(newCall(newIdentNode("check"), node)) else: let lineinfo = newStrLitNode(checked.lineInfo) diff --git a/testament/important_packages.nim b/testament/important_packages.nim index 972bb3faa..58f07b017 100644 --- a/testament/important_packages.nim +++ b/testament/important_packages.nim @@ -9,7 +9,7 @@ var packages2*: seq[tuple[name, cmd: string; hasDeps: bool; url: string, useHead # packages A-M -pkg1 "alea", true +# pkg1 "alea", true pkg1 "argparse" pkg1 "arraymancer", true, "nim c tests/tests_cpu.nim" pkg1 "ast_pattern_matching", false, "nim c -r --oldgensym:on tests/test1.nim" diff --git a/tests/macros/tmemit.nim b/tests/macros/tmemit.nim index 06ab8a1e2..6c9f9f935 100644 --- a/tests/macros/tmemit.nim +++ b/tests/macros/tmemit.nim @@ -1,6 +1,5 @@ discard """ output: ''' -HELLO WORLD c_func 12 ''' @@ -8,8 +7,6 @@ c_func import macros, strutils -emit("echo " & '"' & "hello world".toUpperAscii & '"') - # bug #1025 macro foo(icname): untyped = diff --git a/tests/showoff/tformatopt.nim b/tests/showoff/tformatopt.nim index 6e790c38e..420dd026b 100644 --- a/tests/showoff/tformatopt.nim +++ b/tests/showoff/tformatopt.nim @@ -37,7 +37,7 @@ macro optFormat{`%`(f, a)}(f: string{lit}, a: openArray[string]): untyped = result = newNimNode(nnkBracket) let f = f.strVal formatImpl(newLit) - result = nestList(!"&", result) + result = nestList(newIdentNode("&"), result) template optAdd1{x = y; add(x, z)}(x, y, z: string) = x = y & z diff --git a/tests/usingstmt/tusingstatement.nim b/tests/usingstmt/tusingstatement.nim index 6e4998892..dd4cf589d 100644 --- a/tests/usingstmt/tusingstatement.nim +++ b/tests/usingstmt/tusingstatement.nim @@ -38,7 +38,7 @@ macro autoClose(args: varargs[untyped]): untyped = varAssignment.add(varValue) variables.add(varAssignment) - closingCalls.add(newCall(!"close", varName)) + closingCalls.add(newCall(newIdentNode("close"), varName)) else: error "Using statement: Unexpected expression. Got " & $args[i].kind & " instead of assignment."