From de5f6a07c239ccf5ca3d41d70350a37112025bcf Mon Sep 17 00:00:00 2001 From: zah Date: Mon, 28 Oct 2019 23:45:55 +0200 Subject: Fix newLit for objects having string fields (#12542) [backport] --- lib/core/macros.nim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib') 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))``. -- cgit 1.4.1-2-gfad0