;;;; A dyn value produced inside a defer, on a function a transfer leaves ;;;; through rather than returns from. ;;;; ;;;; This is here for the root count and not for the arithmetic. A defer appears ;;;; twice in the typed IR — spliced into the body for the normal path, and ;;;; again in fdefers for the path a handled condition unwinds along — so the ;;;; emitter produces two copies of every dyn temporary inside one. Counting ;;;; only the body left the second copy's temporaries in slots the collector had ;;;; never been told about: the pushes and the pops still balanced, so nothing ;;;; failed, and the values were simply invisible. ;;;; ;;;; Nothing the stub does can show that, because it never collects. What shows ;;;; it is the emitted IR — a fallback slot is spelled %dx and a rooted one %dr, ;;;; and the fix is the absence of the former. (defstruct Boom [n i64]) (defn inner [x] dyn (defer (print (+ x 1000)) (print "\n")) (restart-case (error (Boom {.n 1})) (give [] 0)) (+ x 1)) (defn main [] () (handler-bind [(Boom [b] (invoke-restart 'give))] (print (inner 5)) (print "\n")))