Fix redefinition of 'T`gensymXX' error

In rare instances, the Nim compiler will generate the same
symbol more than once. Adding a block works around this issue.

Reproducing this behavior in a unit test has proved elusive.
This commit is contained in:
Mark Spanbroek 2022-10-20 12:08:51 +02:00
parent 30e4184a99
commit ab56220011

View File

@ -4,8 +4,9 @@ macro `.?`*(expression: typed, brackets: untyped{nkBracket}): untyped =
# chain is of shape: expression.?[index] # chain is of shape: expression.?[index]
let index = brackets[0] let index = brackets[0]
quote do: quote do:
type T = typeof(`expression`[`index`]) block:
try: type T = typeof(`expression`[`index`])
`expression`[`index`].some try:
except KeyError: `expression`[`index`].some
T.none except KeyError:
T.none