mirror of
https://github.com/logos-storage/questionable.git
synced 2026-01-05 15:23:08 +00:00
Create identifiers with genSym
This commit is contained in:
parent
8ed9709da4
commit
6226cbc49a
@ -45,9 +45,9 @@ proc newUnpackTupleNode(names: NimNode, value: NimNode): NimNode =
|
|||||||
nnkLetSection.newTree(vartuple)
|
nnkLetSection.newTree(vartuple)
|
||||||
|
|
||||||
macro bindTuple(names, expression): bool =
|
macro bindTuple(names, expression): bool =
|
||||||
let opt = ident("option")
|
let opt = genSym(nskLet, "option")
|
||||||
let evaluated = ident("evaluated")
|
let evaluated = genSym(nskLet, "evaluated")
|
||||||
let T = ident("T")
|
let T = genSym(nskType, "T")
|
||||||
|
|
||||||
let value = quote do:
|
let value = quote do:
|
||||||
if `opt`.isSome:
|
if `opt`.isSome:
|
||||||
|
|||||||
@ -288,6 +288,15 @@ suite "optionals":
|
|||||||
else:
|
else:
|
||||||
fail()
|
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":
|
test "without statement can be used for early returns":
|
||||||
proc test1 =
|
proc test1 =
|
||||||
without a =? 42.some:
|
without a =? 42.some:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user