An additional piece of information. I passed the equivalent source code to the
`dumpCompiledCode` macro instead of the output from `refObjectDestructor`:
dumpCompiledCode:
proc `=destroy`(x: typeof(Marker()[])) =
`=destroy`(x.tref)
Run
The result was
AST generated by the `refObjectDestructor` macro (obtained by inserting `echo
treerepr(result)` at the end of the macro):
ProcDef
AccQuoted
Ident "="
Ident "destroy"
Empty
Empty
FormalParams
Empty
IdentDefs
Ident "x"
I would compare the ast you generate with the ast of a dumpAstGen
I think that may help at execution time, but not at compile time. Other code
that I've written that doesn't use the macros and without the nil check worked
fine.
Wild guess here, but you need to check for nil!
I have been writing some helper macros to assist in the coding of destructors,
and I ran into the following problem.
import macros
macro dumpCompiledCode(compiledCode: typed): untyped =
## Simple macro to dump the final generated source code form of the
argument,