mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-08 05:53:22 +00:00
Fix newLit for objects having string fields (#12542) [backport]
This commit is contained in:
@@ -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))``.
|
||||
|
||||
Reference in New Issue
Block a user