Fix newLit for objects having string fields (#12542) [backport]
This commit is contained in:
parent
44b1ecc287
commit
de5f6a07c2
1 changed files with 5 additions and 5 deletions
|
|
@ -720,6 +720,11 @@ proc newLit*(b: bool): NimNode {.compileTime.} =
|
||||||
## Produces a new boolean literal node.
|
## Produces a new boolean literal node.
|
||||||
result = if b: bindSym"true" else: bindSym"false"
|
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:
|
when false:
|
||||||
# the float type is not really a distinct type as described in https://github.com/nim-lang/Nim/issues/5875
|
# 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.} =
|
proc newLit*(f: float): NimNode {.compileTime.} =
|
||||||
|
|
@ -793,11 +798,6 @@ proc newLit*(arg: tuple): NimNode {.compileTime.} =
|
||||||
for a,b in arg.fieldPairs:
|
for a,b in arg.fieldPairs:
|
||||||
result.add nnkExprColonExpr.newTree(newIdentNode(a), newLit(b))
|
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.} =
|
proc nestList*(op: NimNode; pack: NimNode): NimNode {.compileTime.} =
|
||||||
## Nests the list `pack` into a tree of call expressions:
|
## Nests the list `pack` into a tree of call expressions:
|
||||||
## ``[a, b, c]`` is transformed into ``op(a, op(c, d))``.
|
## ``[a, b, c]`` is transformed into ``op(a, op(c, d))``.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue