diff options
author | zah <zahary@gmail.com> | 2019-10-28 23:45:55 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-10-28 22:45:55 +0100 |
commit | de5f6a07c239ccf5ca3d41d70350a37112025bcf (patch) | |
tree | 59774cd1f7127e0e1ca2d8dae3ad66fd1d4513d4 /lib/core | |
parent | 44b1ecc287fec603a9f24995ce6401ad0d109c55 (diff) | |
download | Nim-de5f6a07c239ccf5ca3d41d70350a37112025bcf.tar.gz |
Fix newLit for objects having string fields (#12542) [backport]
Diffstat (limited to 'lib/core')
-rw-r--r-- | lib/core/macros.nim | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/core/macros.nim b/lib/core/macros.nim index cd4a3c48f..16e859092 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -720,6 +720,11 @@ proc newLit*(b: bool): NimNode {.compileTime.} = ## Produces a new boolean literal node. result = if b: bindSym"true" else: bindSym"false" +proc newLit*(s: string): NimNode {.compileTime.} = + ## Produces a new string literal node. + result = newNimNode(nnkStrLit) + result.strVal = s + when false: # the float type is not really a distinct type as described in https://github.com/nim-lang/Nim/issues/5875 proc newLit*(f: float): NimNode {.compileTime.} = @@ -793,11 +798,6 @@ proc newLit*(arg: tuple): NimNode {.compileTime.} = for a,b in arg.fieldPairs: result.add nnkExprColonExpr.newTree(newIdentNode(a), newLit(b)) -proc newLit*(s: string): NimNode {.compileTime.} = - ## Produces a new string literal node. - result = newNimNode(nnkStrLit) - result.strVal = s - proc nestList*(op: NimNode; pack: NimNode): NimNode {.compileTime.} = ## Nests the list `pack` into a tree of call expressions: ## ``[a, b, c]`` is transformed into ``op(a, op(c, d))``. |