Repository navigation
Description
Restated (2026-10-25 triage)
Builtin List.new_in(allocator) (§8.3; Vec is List since D118): a List whose growth uses the supplied allocator, ephemeral when the allocator is borrowed, storable when owned.
Original report
Summary
#437 implemented the honest first step from its plan: real Arena, FrameArena, PoolAllocator, and an ephemeral ArenaVec[T] that stores elements in a borrowed arena. The remaining spec end-state is builtin standard-container allocator support: Vec.new_in(allocator) should construct a normal Vec[T] whose growth path uses the supplied allocator instead of the global heap.
Spec
§8.3 says standard containers accept an optional allocator parameter. The example uses:
fn example(arena: &FrameArena):
var candidates = Vec.new_in(arena)
candidates.push(1)
A container initialized with a borrowed allocator stores the borrow and becomes ephemeral; a container initialized with an owned allocator handle is storable.
Current state
lib/std/alloc.wnow has real region/frame/pool allocators andArenaVec[T]coverage.- Builtin
Vec[T]is still a compiler/runtime-owned layout:{ ptr, len, cap, elem_size }inlib/std/collections.wandrt/rt_core.w. - Runtime growth (
with_vec_*) uses the global allocator unconditionally. - There is no allocator slot in the builtin Vec header and no codegen lowering for
Vec.new_in.
Required implementation
- Decide and document the builtin Vec allocator ABI. Likely extend the Vec header with an allocator kind/handle slot, or introduce a side table if layout stability is required.
- Update the runtime
with_vec_*allocation/growth/free paths to dispatch through the selected allocator. Borrowed arena/frame allocators must not individually free element buffers; global heap Vecs keep current behavior. - Add compiler lowering for
Vec.new_in(arena)andVec.new_in(owned_handle). - Preserve bootstrap discipline: if
rt/*.wlayout/runtime changes are required, follow AGENTS.md bootstrap rules and keep runtime/link-consumer changes independently fixpoint-green. - Apply allocator ephemerality:
Vec.new_in(&Arena)/Vec.new_in(&FrameArena)is ephemeral; owned allocator handles become storable once owned handles exist. - Keep
Vec.new()behavior and existing Vec tests unchanged.
Tests
- Positive:
Vec.new_in(&arena)push/get/len works and uses arena-backed growth. - Negative: borrowed-allocator
Veccannot be stored in a non-ephemeral struct or returned beyond the allocator scope. - Positive: ordinary
Vec.new()remains heap-backed and storable. - Runtime: arena reset/drop semantics are not violated by Vec growth.
- Bootstrap: full
with build,with build :fixpoint,with build :test, andwith build :test-greenpass.
Dependencies / notes
- Builds on First-class allocators: real Arena/FrameArena/Pool, Vec.new_in, ephemeral virality (§8.3) #437.
- Owned allocator handles depend on the
Rc/owned handle work tracked elsewhere. - Generic constructor inference for return-only type parameters is still part of the broader generics substrate tracked in Fix sema generic type instantiation (TY_GENERIC_INST erasure) — prerequisite for stdlib-as-generics #391; builtin lowering may avoid that by treating
Vec.new_inlike existingVec.new.
Activity
[-]Builtin Vec.new_in allocator ABI (§8.3)[/-][+]List.new_in(allocator): allocator-parameterized builtin List (§8.3)[/+]ehartford commentedon Oct 25, 2026
Triage 2026-10-25,
with v0.15.3.0(main a261b65): still reproduces. §8.3's example (now spelledList, D118) is refused:post-release: allocator-parameterized builtin containers are a runtime and lowering campaign.
sema: do not propagate ephemeral flag across contextual Copy derefs i…
sema: top-level function address &fn_name is static, not ephemeral (#570
Wave 3: @[ffi_stack] (#583), List.new_in(allocator) (#570), float Min…