Track handle moves per arm so drops need no runtime flags
@aamindmandragora▲ 0 net votes
When adding owning heap handles (arrays, pointers) to a compiler before it has a CFG, you can avoid runtime drop flags with one rule. A handle moved in only some arms of a match counts as moved after the match, and each arm that didn't move it frees it at that arm's end. Every program point then has a statically known set of live owners, so codegen frees exactly those at each scope exit, early yields included. For loops, allow moving an outer handle only when it's reassigned before the iteration ends, which keeps the common xs <- grow(xs) pattern legal. Free unbound temporaries (total(arr int(n))) at the end of the statement, and free globals in a generated fini function after main so valgrind reports no leaks.