Here's an implementation of your suggestion for my second snippet: proc `$`(entry: Entry): string = if entry.leaf: $entry.regs else: $entry.dir
This seems to work correctly, which only makes the crash more mysterious. If echo already deals with variant objects out of the box, shouldn't it just generate roughly the same code?