Create identifiers with `genSym`
This commit is contained in:
parent
440debc7c3
commit
fe47a19825
|
@ -45,9 +45,9 @@ proc newUnpackTupleNode(names: NimNode, value: NimNode): NimNode =
|
|||
nnkLetSection.newTree(vartuple)
|
||||
|
||||
macro bindTuple(names, expression): bool =
|
||||
let opt = ident("option")
|
||||
let evaluated = ident("evaluated")
|
||||
let T = ident("T")
|
||||
let opt = genSym(nskLet, "option")
|
||||
let evaluated = genSym(nskLet, "evaluated")
|
||||
let T = genSym(nskType, "T")
|
||||
|
||||
let value = quote do:
|
||||
if `opt`.isSome:
|
||||
|
|
|
@ -288,6 +288,15 @@ suite "optionals":
|
|||
else:
|
||||
fail()
|
||||
|
||||
test "=? for tuples does not leak symbols into caller's scope":
|
||||
const evaluated = ""
|
||||
type T = string
|
||||
if (a,) =? some (0,):
|
||||
check a == 0
|
||||
check option is proc
|
||||
check evaluated is string
|
||||
check T is string
|
||||
|
||||
test "without statement can be used for early returns":
|
||||
proc test1 =
|
||||
without a =? 42.some:
|
||||
|
|
Loading…
Reference in New Issue