;;;; The context allocator holds an Allocator value, incarnation and all. Here ;;;; the inner with-allocator destroys the arena the outer one installed, and ;;;; on the way out the outer one is put back; the next arena-new takes the ;;;; destroyed arena's record. Allocating from the context must then trap, ;;;; not quietly allocate from the new arena. Argument 1 reads context/allocator ;;;; as a value first and uses that instead, which traps the same way. (defn main [args [str]] i32 (let [which (if (> (length args) 1) (bytes->i64 (bytes-view (at args 1))) 0) a (arena-new 4096)] (with-allocator a (let [held context/allocator] (with-allocator (heap-allocator) (arena-destroy a)) (let [b (arena-new 4096) w (vec-new i32 b)] (push w 5) (println (at w 0)) (if (= which 1) (let [v (vec-new i32 held)] (push v 1)) (let [v (vec-new i32)] (push v 1))) (println "unreachable"))))) 0)