diff --git a/questionable/withoutresult.nim b/questionable/withoutresult.nim index a34ccff..cabba18 100644 --- a/questionable/withoutresult.nim +++ b/questionable/withoutresult.nim @@ -2,12 +2,32 @@ import std/macros import ./without import ./private/binderror -macro without*(condition, errorname, body): untyped = +proc undoSymbolResolution(expression, ident: NimNode): NimNode = + ## Finds symbols in the expression that match the `ident` and replaces them + ## with `ident`, effectively undoing any symbol resolution that happened + ## before. + + const symbolKinds = {nnkSym, nnkOpenSymChoice, nnkClosedSymChoice} + + if expression.kind in symbolKinds and eqIdent($expression, $ident): + return ident + + for i in 0..