Better error message when adding a void result to a .? chain

This commit is contained in:
Mark Spanbroek 2021-05-06 17:28:58 +02:00
parent dd9ac6dc20
commit d18580bb68
1 changed files with 2 additions and 0 deletions

View File

@ -9,6 +9,8 @@ func expectSym(node: NimNode) =
template `.?`*(option: typed, identifier: untyped{nkIdent}): untyped =
# chain is of shape: option.?identifier
when not compiles(typeof(option.unsafeGet.identifier)):
{.error: ".? chain cannot return void".}
option ->? option.unsafeGet.identifier
macro `.?`*(option: typed, infix: untyped{nkInfix}): untyped =