Repository navigation
Stdlib sourcing close-out: Stack/Queue/LinkedList, stable_sort/shuffle, word shapes, the slot API, #2560/#2565 fixed - #2614
Merged
Merged
Conversation
added 13 commits
October 24, 2026 18:52
…e_isize for indices (D108) next_i32 at the minimum value negated overflowed in range_i32 and chance; a non-negative draw is the sign bit masked off. range_isize draws an index in [lo, hi) from the 63-bit word, for the algorithms that shuffle.
…rd-key hset and the word pqueue (D148); the corpus re-promoted under inputs: The facade shapes unit is the corpus source (D112), so the trigger is inputs:shapes. The test corpus defs.w files carry the shared declarations with it.
…he slot lifetime written once (D148) stc_word holds stc_is_word/stc_to_word/stc_from_word and the ordered-word pair the STC facades share; Deque imports them instead of its own copies. stc_slot gains the slot lifetime — stc_slot_new (safe: it moves a value in), and the unsafe fns stc_slot_view/stc_slot_take/stc_slot_release over the typed slot pointer (the compiler is right that a function relying on a raw pointer's validity is unsafe; the cast at the call site carries T, which a call never spells) — the probe (stc_slot_probe/stc_slot_discard_probe) and the map entry (StcEntry, stc_entry_new/key/value/take/release). Deque, PriorityQueue, OrderedSet, OrderedMap, UnorderedSet and UnorderedMap call them; a `get -> Option[&T] from self` still derives its view from self in its own body, as §21.1 rule 6 requires. The unsafe left in a facade is the engine call and the slot lifetime step beside it (Eric, 2026-10-24: the slot alloc/take/view repeated per facade was the ceremony signal).
…ap rows evaluated separately) STC sort.h is a quicksort with an insertion-sort tail and promises no order among equal elements, so the stable sort is a merge sort over the same reference layout (element addresses merged bottom-up, then one permutation by bits, every element moved exactly once); the sourcing rule owns a primitive this small. shuffle is a Fisher-Yates through std.random (the With RNG; STC c_shuffle_array is a macro over its own generator). find/position/index_of/contains were already the language iterator adapters, not facade rows. Fixture behav_list_stable_sort; complexity row stable-sort; benchmark row (n = 100000: stable_sort 53 ns per i64, stable_sort_by 84 ns per pair, beside sort 34/223).
…s (D148: the next row when a hot path needs it) UnorderedSet[int] keys the engine hset by the word itself (no slot, no probe allocation); PriorityQueue keeps a max-queue of a signed word (i8..i64, u8..u32, isize) inline in the engine heap, readable in place at the top; a min-queue or an unsigned 64-bit key rides the slot shape. Measured (test/benchmark/stc_engines.w, n = 100000, ns per op insert/lookup/remove): UnorderedSet[i32] 12/1/3 against the slot shape 86/61/115 and HashSet 74/27/25; PriorityQueue[i32] 3/0/24 against the slot shape 19/0/104 and BinaryHeap 17/0/111. Fixtures extended; complexity rows priority-queue-slots and unordered-set-slots keep the slot shapes measured.
…acade map rows; slot and word shapes, D148) std.collections.stack.Stack[T] (push/pop/peek/get/iter), std.collections.queue.Queue[T] (push/pop/front/back/iter) and std.collections.linked_list.LinkedList[T] (push at both ends, pop_front, front/back, iter, reverse, sort; the facade counts, the engine count walks). Each owns its values; pops transfer, views observe (D27/D22), drops release the rest exactly once. Fixtures behav_stack/behav_queue/behav_linked_list, complexity rows stack/queue/linked-list, drop-audit cells, benchmark rows (n = 100000: Stack[i32] 2/0/0, Queue[i32] 2/0/0, LinkedList[i32] 9/8/11, beside List 2/0/1).
…no longer reproduces) A nested std module imports a corpus pub let and a generic type through whole-module uses today (probed with a module under lib/std/collections importing std.engines.c_algorithms.defs and std.collections.engine_slot: both resolve). The local HEAP_TYPE_* constants spelled around the gap are gone; the facade is the standing regression test, since std compiles in every battery.
…coerced to extern "C" fn, is a C-ABI entry when the sorted-array engine calls it The crash the issue reported no longer reproduces (the issue's own repro prints 3; qsort through the same shape sorts). While re-reproducing it, an `isize` sample over `i32` values read eight bytes and ordered garbage: the program's mistake (`with analyze ... matrix` showed the closure's callee as isize.cmp), noted in the fixture.
… the specialized get/set per subscript, MIR lowers the recorded callee (#2560, D65); Deque and Stack spell d[i] A bounded blanket impl (impl[T: Copy] IndexPlace[isize, T] for Box3[T]) was invisible: type_is_index_place asked select_trait_impl about the base symbol, whose bounds never match; the subscript check now settles the instance through type_implements_trait (IndexPlace or IndexGet) and records it (index_place_insts) for the read-only classification. The subscript's callee was re-derived by MirLower from the type's name (lookup_method_fn of the generic declaration, whose get returns the unsubstituted T: "cannot infer type parameter"); Sema now specializes get and set for the receiver (record_index_place_contracts, as record_btree_new_contract does) and MirLower lowers the recorded (fn, sig, mono) through lower_resolved_call_with_operand_args_contract for reads, stores, compound stores and the store's read-back, borrowing the receiver place for a get(self: &Self) (the contract made the validator see the old value-passed receiver). A subscript lowered as a place (a call argument) materializes the read into a temp instead of entering lower_index. An IndexGet-only type refuses a store ("type does not support index assignment"). Deque and Stack implement IndexGet[isize, &T] (their get moves into the impl): d[i] is the element's view, as the facade doc promised. Fixtures behav_index_place_generic (bounded and unbounded impls, two instantiations, compound store, the subscript as a call argument, IndexGet views), behav_deque and behav_stack (d[i]).
…lves to the tuple type (#2565) In type-level position a tuple type parses as a tuple expression of types, which resolve_type_level_arg_expr did not resolve; the instance then had no concrete argument, its methods no specialization contract (BUG: user generic call lacks a concrete contract), and a field read through the method's &T view had no type (the inference error on print). The same type in an annotation always worked. Fixture behav_tuple_type_argument (a box and the Deque, nested tuples, the view's fields, a consuming pop).
…eue/LinkedList, stable_sort/shuffle, word shapes, the slot API, the closed defects) and what remains as briefs The facade map rows move to Done with their dates; "What remains" lists the two rulings (List over STC vec: prediction rt_core stays, as D149; Span: a std.span over cspan_md after a use case), cstr, the internal engines, heap utilities, and the engine-call unsafe (migrator-emitted contracts, the ruling Eric raised).
…de a comparator instead of cloning one; the IndexPlace store call is a statement, not a `let _`
… user IndexPlace type_is_index_place answers yes for every positional kind (arrays, slices, vectors, masks) so the place classifier can treat `v[i] = x` as a store; MirLower's user-IndexPlace test excluded arrays and slices but not vectors and masks, which the recorded-contract lowering then refused (eighteen behav_1874_simd_* and over-aligned-payload tests aborted in the battery: "a user IndexPlace read has no recorded get contract"). The exclusion names them.
Contributor
Author
|
Seed-driven battery GREEN on 6f63180 (wall 577 s; gate, uat, battery-checks; drop-audit and deep-debug-tool-tests green before it). |
ehartford
marked this pull request as ready for review
October 24, 2026 23:41
This was referenced Oct 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes out
docs/proposals/stdlib_sourcing_plan.md's open facade-map rows and the compiler defects the facades found. Twelve commits, one logical change each.Facades (STC, D148 slot and word shapes):
Stack,Queue,LinkedList(new;std.collections.stack/queue/linked_list);PriorityQueueandUnorderedSettake the word shape for integer scalars;DequeandStackspelld[i]throughIndexGet. The shapes unit grew the instantiations and the STC corpus was re-promoted underinputs:shapes(D112).Algorithms:
List.stable_sort/stable_sort_by(STC's sort has no stability contract, so a merge sort over the same reference layout, owned) andshuffle(Fisher–Yates over std.random).std.randomdraws mask the sign bit (#1058) and gainrange_isize.The slot API:
stc_slotholds the slot and entry lifetime once (stc_slot_new, the unsafestc_slot_view/take/releaseover typed slot pointers, the probe,StcEntry);stc_wordholds the word conversions. Every STC facade uses them; theunsafeleft in a facade is the engine call and the slot step beside it.Compiler: #2560 (IndexPlace/IndexGet on a generic user type: Sema records the specialized
get/setper subscript, MIR lowers the recorded callee, D65), #2565 (a tuple type argument at a static call). #1135 and #1136 no longer reproduce: a fixture pins #1135,BinaryHeapdrops its #1136 workaround.Measured (
test/benchmark/stc_engines.w, n = 100000, ns per op insert/lookup/remove):UnorderedSet[i32]11/1/3 (word) vs 90/65/122 (slot) vsHashSet76/27/25;PriorityQueue[i32]4/0/23 (word) vs 23/0/114 (slot);Stack[i32]2/0/0,Queue[i32]2/0/0,LinkedList[i32]9/8/12,List2/0/1;stable_sort51 ns per i64, 84 per pair (sort 36/242).Battery: seed-driven, posted below when green.