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"
Call
Ident "typeof"
BracketExpr
Call
Ident "Marker"
Empty
Empty
Empty
StmtList
Call
AccQuoted
Ident "="
Ident "destroy"
DotExpr
Ident "x"
Ident "tref"
Run
I then dumped the AST of the code that the macro was intended to generate:
dumpTree:
proc `=destroy`(x: typeof(Marker()[])) =
`=destroy`(x.tref)
Run
The resulting AST is:
StmtList
ProcDef
AccQuoted
Ident "="
Ident "destroy"
Empty
Empty
FormalParams
Empty
IdentDefs
Ident "x"
Call
Ident "typeof"
BracketExpr
Call
Ident "Marker"
Empty
Empty
Empty
StmtList
Call
AccQuoted
Ident "="
Ident "destroy"
DotExpr
Ident "x"
Ident "tref"
Run
The only difference between the two is an enclosing `StmtList` node in the
latter. I tried altering the `refObjectDestructor` macro to include the
enclosing `StmtList`. It has no effect; the compiler still crashes.