nim-stew/tests/test_results2.nim
Jacek Sieka 447b23d3bf
results: work around field access bugs (#167)
* results: work around field access bugs

See:

* https://github.com/nim-lang/Nim/issues/3770
* https://github.com/nim-lang/Nim/issues/20900

* comment fixes

* add test

* document test better
2023-01-20 15:32:51 +01:00

14 lines
387 B
Nim

import ../stew/results
{.used.}
# Oddly, this piece of code works when placed in `test_results.nim`
# See also https://github.com/status-im/nim-stew/pull/167
template repeater(b: Opt[int]): untyped =
# Check that Result can be used inside a template - this fails
# sometimes with field access errors as noted in above issue
b
let x = repeater(Opt.none(int))
doAssert x.isNone()