Section 7C: Collections & Iteration
Goal: Collection methods, iterator traits, and Debug trait
SPEC:
spec/annex-c-built-in-functions.mdDESIGN:modules/prelude.md
7C.1 Collection Functions
NOTE:
lenandis_emptyare being moved from free functions to methods on collections (see 7C.4). The free function forms are deprecated in favor of.len()and.is_empty()methods. Keep backward compatibility during transition, then remove free functions.
-
Implement:
len(x)— spec/annex-c-built-in-functions.md § len (deprecated, use.len()) [done] (2026-02-10) (verified 2026-03-29)- Rust Tests: Evaluator builtin — len function tests
- Ori Tests: Used extensively in test suite via
.len()method - LLVM Support: Free function delegates to method form; method
.len()has full LLVM codegen (see 7C.4) (verified 2026-03-29) - AOT Tests: Method form
.len()covered in 7C.4 with passing AOT tests (verified 2026-03-29)
-
Implement:
is_empty(x)— spec/annex-c-built-in-functions.md § is_empty (deprecated, use.is_empty()) [done] (2026-02-10) (verified 2026-03-29)- Rust Tests: Evaluator builtin — is_empty function tests
- Ori Tests:
tests/spec/traits/core/is_empty.ori— 10 test functions (verified 2026-03-29) - LLVM Support: Free function delegates to method form; method
.is_empty()has full LLVM codegen (see 7C.4) (verified 2026-03-29) - AOT Tests: Method form
.is_empty()covered in 7C.4 with passing AOT tests (verified 2026-03-29)
7C.2 Collection Methods on [T]
Design Principle: Lean core, rich libraries. Data transformation is stdlib, not compiler patterns.
-
Implement:
[T].map(f: T -> U) -> [U]— modules/prelude.md § List [done] (2026-02-10) (verified 2026-03-29)- Rust Tests: Evaluator method dispatch — list map tests
- Ori Tests:
tests/spec/traits/iterator/methods.ori— iter_map; also used intests/spec/types/primitives.ori,tests/spec/lexical/keywords.ori(verified 2026-03-29) - LLVM Support: Works via iterator pipeline; AOT tests demonstrate LLVM codegen (verified 2026-03-29)
- AOT Tests:
ori_llvm/tests/aot/iterators.rs—test_iter_map(iterator-level.map(), 1 test);ori_llvm/tests/aot/collections_ext.rs—test_coll_list_iter_map_collect_length(1 test)
-
Implement:
[T].filter(f: T -> bool) -> [T]— modules/prelude.md § List [done] (2026-02-10) (verified 2026-03-29)- Rust Tests: Evaluator method dispatch — list filter tests
- Ori Tests:
tests/spec/traits/iterator/methods.ori— iter_filter;tests/spec/lexical/operators.ori—list.filter(predicate:)(verified 2026-03-29) - LLVM Support: Works via iterator pipeline; AOT tests demonstrate LLVM codegen (verified 2026-03-29)
- AOT Tests:
ori_llvm/tests/aot/iterators.rs—test_iter_filter(iterator-level.filter(), 1 test);ori_llvm/tests/aot/collections_ext.rs—test_coll_list_iter_filter_count(1 test)
-
Implement:
[T].fold(initial: U, f: (U, T) -> U) -> U— modules/prelude.md § List [done] (2026-02-10) (verified 2026-03-29)- Rust Tests: Evaluator method dispatch — list fold tests
- Ori Tests:
tests/spec/traits/iterator/methods.ori— iter_fold;tests/spec/lexical/keywords.ori— fold usage (verified 2026-03-29) - LLVM Support: Works via iterator pipeline; AOT tests demonstrate LLVM codegen (verified 2026-03-29)
- AOT Tests:
ori_llvm/tests/aot/iterators.rs—test_iter_fold_sum,test_iter_fold_with_filter(iterator-level.fold(), 2 tests);ori_llvm/tests/aot/collections_ext.rs—test_coll_list_iter_sum_via_fold(1 test)
-
Implement:
[T].find(f: T -> bool) -> Option<T>— modules/prelude.md § List [done] (verified 2026-03-28) (verified 2026-03-29)- Rust Tests: Evaluator method dispatch — tested via spec tests
- Ori Tests:
tests/spec/traits/iterator/methods.ori— iter_find, iter_find_none (verified 2026-03-29) - LLVM Support: Works via iterator pipeline; AOT tests demonstrate LLVM codegen (verified 2026-03-29)
- AOT Tests:
ori_llvm/tests/aot/iterators.rs—test_iter_find_some,test_iter_find_none(iterator-level.find(), 2 tests)
-
Implement:
[T].any(f: T -> bool) -> bool— modules/prelude.md § List [done] (verified 2026-03-28) (verified 2026-03-29)- Rust Tests: Evaluator method dispatch — tested via spec tests
- Ori Tests:
tests/spec/traits/iterator/methods.ori— iter_any_true, iter_any_false, iter_empty_any (verified 2026-03-29) - LLVM Support: Works via iterator pipeline; AOT tests demonstrate LLVM codegen (verified 2026-03-29)
- AOT Tests:
ori_llvm/tests/aot/iterators.rs—test_iter_any_true,test_iter_any_false(iterator-level.any(), 2 tests);ori_llvm/tests/aot/collections_ext.rs—test_coll_list_iter_any_all(1 test)
-
Implement:
[T].all(f: T -> bool) -> bool— modules/prelude.md § List [done] (verified 2026-03-28) (verified 2026-03-29)- Rust Tests: Evaluator method dispatch — tested via spec tests
- Ori Tests:
tests/spec/traits/iterator/methods.ori— iter_all_true, iter_all_false, iter_empty_all (verified 2026-03-29) - LLVM Support: Works via iterator pipeline; AOT tests demonstrate LLVM codegen (verified 2026-03-29)
- AOT Tests:
ori_llvm/tests/aot/iterators.rs—test_iter_all_true,test_iter_all_false(iterator-level.all(), 2 tests);ori_llvm/tests/aot/collections_ext.rs—test_coll_list_iter_any_all(1 test)
-
Implement:
[T].first() -> Option<T>— modules/prelude.md § List [done] (verified 2026-03-28) (verified 2026-03-29)- Rust Tests: Evaluator method dispatch — tested via AOT tests
- Ori Tests: NEEDS TESTS — no Ori spec test exists for
.first(); needtests/spec/collections/list/first.ori - LLVM Support: Works via AOT codegen; 2 passing AOT tests (verified 2026-03-29)
- AOT Tests:
ori_llvm/tests/aot/collections_ext.rs—test_coll_list_first,test_coll_list_first_empty(2 tests, passing)
-
Implement:
[T].last() -> Option<T>— modules/prelude.md § List [done] (verified 2026-03-28) (verified 2026-03-29)- Rust Tests: Evaluator method dispatch — tested via AOT tests
- Ori Tests: NEEDS TESTS — no Ori spec test exists for
.last(); needtests/spec/collections/list/last.ori - LLVM Support: Works via AOT codegen; 2 passing AOT tests (verified 2026-03-29)
- AOT Tests:
ori_llvm/tests/aot/collections_ext.rs—test_coll_list_last,test_coll_list_last_empty(2 tests, passing)
-
Implement:
[T].take(n: int) -> [T]— modules/prelude.md § List [done] (verified 2026-03-28) (verified 2026-03-29)- Rust Tests: Evaluator method dispatch — tested via spec tests
- Ori Tests:
tests/spec/traits/iterator/methods.ori— iter_take, iter_take_excess (with edge case) (verified 2026-03-29) - LLVM Support: Works via iterator pipeline; AOT tests demonstrate LLVM codegen (verified 2026-03-29)
- AOT Tests:
ori_llvm/tests/aot/iterators.rs—test_iter_take(iterator-level take adapter, 1 test)
-
Implement:
[T].skip(n: int) -> [T]— modules/prelude.md § List [done] (verified 2026-03-28) (verified 2026-03-29)- Rust Tests: Evaluator method dispatch — tested via spec tests
- Ori Tests:
tests/spec/traits/iterator/methods.ori— iter_skip, iter_skip_excess (verified 2026-03-29) - LLVM Support: Works via iterator pipeline; AOT tests demonstrate LLVM codegen (verified 2026-03-29)
- AOT Tests:
ori_llvm/tests/aot/iterators.rs—test_iter_skip(iterator-level skip adapter, 1 test)
-
Implement:
[T].reverse() -> [T]— modules/prelude.md § List [done] (verified 2026-03-28) (verified 2026-03-29)- Rust Tests: Evaluator method dispatch — tested via AOT tests
- Ori Tests: NEEDS TESTS — no Ori spec test exists for
.reverse(); needtests/spec/collections/list/reverse.ori - LLVM Support: Works via AOT codegen; 6 passing AOT tests (verified 2026-03-29)
- AOT Tests:
ori_llvm/tests/aot/collections_ext.rs—test_coll_list_reverse+ 5 variants (6 tests, passing)
-
Implement:
[T].sort() -> [T]whereT: Comparable— modules/prelude.md § List [done] (verified 2026-03-28) (verified 2026-03-29)- Rust Tests: Evaluator method dispatch — tested via AOT tests
- Ori Tests: NEEDS TESTS — no Ori spec test exists for
.sort(); needtests/spec/collections/list/sort.ori - LLVM Support: Works via AOT codegen; 7 passing AOT tests including COW (verified 2026-03-29)
- AOT Tests:
ori_llvm/tests/aot/collections_ext.rs—test_coll_list_sort_ints+ 6 variants including COW (7 tests, passing) [done] (verified 2026-03-28)
-
Implement:
[T].contains(value: T) -> boolwhereT: Eq— modules/prelude.md § List [done] (verified 2026-03-28) (verified 2026-03-29)- Rust Tests: Evaluator method dispatch — tested via AOT tests
- Ori Tests: NEEDS TESTS — no Ori spec test exists for
.contains(); needtests/spec/collections/list/contains.ori - LLVM Support: Works via AOT codegen; 2 passing AOT tests (verified 2026-03-29)
- AOT Tests:
ori_llvm/tests/aot/collections_ext.rs—test_coll_list_contains,test_coll_list_contains_missing(2 tests, passing)
-
Implement:
[T].push(value: T) -> [T]— modules/prelude.md § List [done] (verified 2026-03-28) (verified 2026-03-29)- Rust Tests: Evaluator method dispatch — tested via AOT tests
- Ori Tests: NEEDS TESTS — no Ori spec test exists for
.push(); needtests/spec/collections/list/push.ori - LLVM Support: Works via AOT codegen; 7 passing AOT tests including COW (verified 2026-03-29)
- AOT Tests:
ori_llvm/tests/aot/collections_ext.rs—test_coll_list_push+ 6 variants including COW (7 tests, passing)
-
Implement:
[T].concat(other: [T]) -> [T]— modules/prelude.md § List [done] (verified 2026-03-28) (verified 2026-03-29)- Rust Tests: Evaluator method dispatch — tested via AOT tests
- Ori Tests: NEEDS TESTS — no Ori spec test exists for
.concat(); needtests/spec/collections/list/concat.ori - LLVM Support: Works via AOT codegen; 6 passing AOT tests including COW (verified 2026-03-29)
- AOT Tests:
ori_llvm/tests/aot/collections_ext.rs—test_coll_list_concat_basic+ 5 variants including COW (6 tests, passing) [done] (verified 2026-03-28)
GAP (identified 2026-03-29): The following list methods from the prelude spec are not tracked in this section. They may need to be added or confirmed as covered elsewhere.
-
Implement:
[T].pop() -> (Option<T>, [T])— modules/prelude.md § List- Ori Tests: NEEDS TESTS
- AOT Tests: No AOT coverage yet
-
Implement:
[T].insert(index: int, value: T) -> [T]— modules/prelude.md § List- Ori Tests: NEEDS TESTS
- AOT Tests: No AOT coverage yet
-
Implement:
[T].remove(index: int) -> [T]— modules/prelude.md § List- Ori Tests: NEEDS TESTS
- AOT Tests: No AOT coverage yet
-
Implement:
[T].slice(start: int, end: int) -> [T]— modules/prelude.md § List- Ori Tests: NEEDS TESTS
- AOT Tests: No AOT coverage yet
-
Implement:
[T].updated(key: int, value: T) -> [T]— modules/prelude.md § List- Ori Tests: NEEDS TESTS
- AOT Tests: No AOT coverage yet
-
/tpr-reviewpassed — independent review found no critical or major issues (or all findings triaged) -
/impl-hygiene-reviewpassed — hygiene review clean. MUST run AFTER/tpr-reviewis clean. -
Subsection close-out (7C.2) — MANDATORY before starting the next subsection. Run
/improve-toolingretrospectively on THIS subsection’s debugging journey (per.claude/skills/improve-tooling/SKILL.md“Per-Subsection Workflow”): whichdiagnostics/scripts you ran, where you addeddbg!/tracingcalls, where output was hard to interpret, where test failures gave unhelpful messages, where you ran the same command sequence repeatedly. Forward-look: what tool/log/diagnostic would shorten the next regression in this code path by 10 minutes? Implement improvements NOW (zero deferral) and commit each via SEPARATE/commit-pushusing a valid conventional-commit type (build(diagnostics): ... — surfaced by section-7C.2 retrospective—build/test/chore/ci/docsare valid;tools(...)is rejected by the lefthook commit-msg hook). Mandatory even when nothing felt painful. If genuinely no gaps, document briefly: “Retrospective 7C.2: no tooling gaps”. Update this subsection’sstatusin section frontmatter tocomplete. -
/sync-claudesection-close doc sync — verify Claude artifacts across all section commits. Map changed crates to rules files, check CLAUDE.md, canon.md. Fix drift NOW. -
Repo hygiene check — run
diagnostics/repo-hygiene.sh --checkand clean any detected temp files.
7C.3 Range Methods
NOTE (2026-03-29): Direct
Range.map()/Range.filter()/ etc. methods do not exist. This functionality works through the.iter()pipeline (e.g.,(0..10).iter().map(f).collect()). These items are correctly[ ]— consider whether direct Range methods are needed or if iterator pipeline is sufficient.
-
Implement:
Range.map(f: T -> U) -> [U]— modules/prelude.md § Range — WEAK TESTS: works through.iter()pipeline but no direct method- Ori Tests: NEEDS TESTS (spec tests through
.iter().map()exist inmethods.ori) - AOT Tests:
ori_llvm/tests/aot/iterators.rs—test_iter_maptests map on list iterator;test_chained_map_filter_taketests map on range-derived iterator
- Ori Tests: NEEDS TESTS (spec tests through
-
Implement:
Range.filter(f: T -> bool) -> [T]— modules/prelude.md § Range — WEAK TESTS: works through.iter()pipeline but no direct method- Ori Tests: NEEDS TESTS (spec tests through
.iter().filter()exist inmethods.ori) - AOT Tests:
ori_llvm/tests/aot/iterators.rs—test_iter_filtertests filter on list iterator;test_chained_map_filter_taketests filter on range-derived iterator
- Ori Tests: NEEDS TESTS (spec tests through
-
Implement:
Range.fold(initial: U, f: (U, T) -> U) -> U— modules/prelude.md § Range — WEAK TESTS: works through.iter()pipeline but no direct method- Ori Tests: NEEDS TESTS (spec tests through
.iter().fold()exist inmethods.ori) - AOT Tests:
ori_llvm/tests/aot/iterators.rs—test_iter_fold_sum,test_iter_fold_with_filtertest fold on range-derived iterators via chaining
- Ori Tests: NEEDS TESTS (spec tests through
-
Implement:
Range.collect() -> [T]— modules/prelude.md § Range — works through.iter().collect()but no direct method- Ori Tests:
tests/spec/traits/iterator/methods.orihasrange_iter_collecttest via.iter().collect() - AOT Tests:
ori_llvm/tests/aot/iterators.rs—test_range_iter_collect(range.iter().collect()to list, 1 test)
- Ori Tests:
-
Implement:
Range.contains(value: T) -> bool— modules/prelude.md § Range- Ori Tests: NEEDS TESTS
- AOT Tests: No AOT coverage yet
-
/tpr-reviewpassed — independent review found no critical or major issues (or all findings triaged) -
/impl-hygiene-reviewpassed — hygiene review clean. MUST run AFTER/tpr-reviewis clean. -
Subsection close-out (7C.3) — MANDATORY before starting the next subsection. Run
/improve-toolingretrospectively on THIS subsection’s debugging journey (per.claude/skills/improve-tooling/SKILL.md“Per-Subsection Workflow”): whichdiagnostics/scripts you ran, where you addeddbg!/tracingcalls, where output was hard to interpret, where test failures gave unhelpful messages, where you ran the same command sequence repeatedly. Forward-look: what tool/log/diagnostic would shorten the next regression in this code path by 10 minutes? Implement improvements NOW (zero deferral) and commit each via SEPARATE/commit-pushusing a valid conventional-commit type (build(diagnostics): ... — surfaced by section-7C.3 retrospective—build/test/chore/ci/docsare valid;tools(...)is rejected by the lefthook commit-msg hook). Mandatory even when nothing felt painful. If genuinely no gaps, document briefly: “Retrospective 7C.3: no tooling gaps”. Update this subsection’sstatusin section frontmatter tocomplete. -
/sync-claudesection-close doc sync — verify Claude artifacts across all section commits. Map changed crates to rules files, check CLAUDE.md, canon.md. Fix drift NOW. -
Repo hygiene check — run
diagnostics/repo-hygiene.sh --checkand clean any detected temp files.
7C.4 Collection Methods (len, is_empty)
Move from free functions to methods on collections.
-
Implement:
[T].len() -> int— modules/prelude.md § List [done] (2026-02-10) (verified 2026-03-29)- Rust Tests: Evaluator method dispatch — list len tests
- Ori Tests:
tests/spec/expressions/field_access.ori,tests/spec/lexical/delimiters.ori(verified 2026-03-29) - LLVM Support: Works via AOT codegen; 4 passing AOT tests (verified 2026-03-29)
- AOT Tests:
ori_llvm/tests/aot/collections_ext.rs—test_coll_list_length_empty+ 2 variants,test_coll_list_len_alias(4 tests, 0 ignored)
-
Implement:
[T].is_empty() -> bool— modules/prelude.md § List [done] (2026-02-10) (verified 2026-03-29)- Rust Tests: Evaluator method dispatch — list is_empty tests
- Ori Tests:
tests/spec/traits/core/is_empty.ori— 15+ tests (verified 2026-03-29) - LLVM Support: Works via AOT codegen; 2 passing AOT tests (verified 2026-03-29)
- AOT Tests:
ori_llvm/tests/aot/collections_ext.rs—test_coll_list_is_empty_true,test_coll_list_is_empty_false(2 tests, 0 ignored)
-
Implement:
{K: V}.len() -> int— modules/prelude.md § Map [done] (2026-02-10) (verified 2026-03-29)- Rust Tests: Evaluator method dispatch — map len tests
- Ori Tests:
tests/spec/lexical/delimiters.ori—map.len()tests (verified 2026-03-29) - LLVM Support: Works via AOT codegen; 3 passing AOT tests (verified 2026-03-29)
- AOT Tests:
ori_llvm/tests/aot/collections_ext.rs—test_coll_map_length_basic,test_coll_map_length_one,test_coll_map_len_alias(3 tests, 0 ignored)
-
Implement:
{K: V}.is_empty() -> bool— modules/prelude.md § Map [done] (verified 2026-03-28) (verified 2026-03-29)- Rust Tests: Evaluator method dispatch — tested via spec tests and AOT tests (verified 2026-03-29)
- Ori Tests:
tests/spec/traits/core/is_empty.ori— 2 map is_empty tests [done] (verified 2026-03-28) - LLVM Support: Works via AOT codegen; 2 passing AOT tests (verified 2026-03-29)
- AOT Tests:
ori_llvm/tests/aot/collections_ext.rs—test_coll_map_is_empty_true,test_coll_map_is_empty_false(2 tests, passing) [done] (verified 2026-03-28)
-
Implement:
str.len() -> int— modules/prelude.md § str [done] (2026-02-10) (verified 2026-03-29)- Rust Tests: Evaluator method dispatch — str len tests
- Ori Tests:
tests/spec/expressions/field_access.ori—"hello".len()(verified 2026-03-29) - LLVM Support: Works via AOT codegen; 6 passing AOT tests (verified 2026-03-29)
- AOT Tests:
ori_llvm/tests/aot/strings.rs—test_str_length_basic+ 4 variants,test_str_len_alias(6 tests, 0 ignored)
-
Implement:
str.is_empty() -> bool— modules/prelude.md § str [done] (2026-02-10) (verified 2026-03-29)- Rust Tests: Evaluator method dispatch — str is_empty tests
- Ori Tests:
tests/spec/traits/core/is_empty.ori—"".is_empty(),!"hello".is_empty()(verified 2026-03-29) - LLVM Support: Works via AOT codegen; 3 passing AOT tests (verified 2026-03-29)
- AOT Tests:
ori_llvm/tests/aot/strings.rs—test_str_is_empty_true,test_str_is_empty_false,test_str_is_empty_space(3 tests, 0 ignored)
-
Implement:
Set<T>.len() -> int— modules/prelude.md § Set [done] (2026-02-25) (verified 2026-03-29)- Rust Tests:
ori_eval/src/methods/helpers/mod.rs— set len inTYPECK_BUILTIN_METHODS - Ori Tests:
tests/spec/types/set_methods/set_methods.ori— set len tests (verified 2026-03-29) - LLVM Support:
ori_llvm/src/codegen/arc_emitter/builtins/collections.rs—emit_set_length()(verified 2026-03-29) - AOT Tests:
ori_llvm/tests/aot/sets.rs—test_aot_set_length(passing) (2026-03-01) (verified 2026-03-29)
- Rust Tests:
-
Implement:
Set<T>.is_empty() -> bool— modules/prelude.md § Set [done] (2026-02-25) (verified 2026-03-29)- Rust Tests:
ori_eval/src/methods/helpers/mod.rs— set is_empty inTYPECK_BUILTIN_METHODS - Ori Tests:
tests/spec/types/set_methods/set_methods.ori— set is_empty tests (verified 2026-03-29) - LLVM Support:
ori_llvm/src/codegen/arc_emitter/builtins/collections.rs—emit_set_is_empty()(verified 2026-03-29) - AOT Tests:
ori_llvm/tests/aot/sets.rs—test_aot_set_is_empty(passing) (2026-03-01) (verified 2026-03-29)
- Rust Tests:
-
Implement:
Set<T>.contains(elem) -> bool— modules/prelude.md § Set [done] (2026-02-25) (verified 2026-03-29)- Evaluator:
ori_eval/src/methods/collections.rs— set contains dispatch - Ori Tests:
tests/spec/types/set_methods/set_methods.ori— set contains tests (verified 2026-03-29) - LLVM Support:
ori_llvm/src/codegen/arc_emitter/builtins/collections.rs—emit_set_contains()viaori_set_containsruntime (verified 2026-03-29) - AOT Tests:
ori_llvm/tests/aot/sets.rs—test_aot_set_contains(passing) (2026-03-01) (verified 2026-03-29)
- Evaluator:
-
Implement:
Set<T>.insert(elem) -> Set<T>— modules/prelude.md § Set [done] (2026-02-25) (verified 2026-03-29)- Evaluator:
ori_eval/src/methods/collections.rs— set insert dispatch - Ori Tests:
tests/spec/types/set_methods/set_methods.ori— set insert tests (verified 2026-03-29) - LLVM Support:
ori_llvm/src/codegen/arc_emitter/builtins/collections.rs—emit_set_insert()viaori_set_insertruntime (sret) (verified 2026-03-29) - AOT Tests:
ori_llvm/tests/aot/sets.rs—test_aot_set_insert(passing) (2026-03-01) (verified 2026-03-29)
- Evaluator:
-
Implement:
Set<T>.remove(elem) -> Set<T>— modules/prelude.md § Set [done] (2026-02-25) (verified 2026-03-29)- Evaluator:
ori_eval/src/methods/collections.rs— set remove dispatch - Ori Tests:
tests/spec/types/set_methods/set_methods.ori— set remove tests (verified 2026-03-29) - LLVM Support:
ori_llvm/src/codegen/arc_emitter/builtins/collections.rs—emit_set_remove()viaori_set_removeruntime (sret) (verified 2026-03-29) - AOT Tests:
ori_llvm/tests/aot/sets.rs—test_aot_set_remove(passing) (2026-03-01) (verified 2026-03-29)
- Evaluator:
-
Implement:
Set<T>.union(other) -> Set<T>— modules/prelude.md § Set [done] (2026-02-25) (verified 2026-03-29)- Evaluator:
ori_eval/src/methods/collections.rs— set union dispatch - Ori Tests:
tests/spec/types/set_methods/set_methods.ori— set union tests (verified 2026-03-29) - LLVM Support:
ori_llvm/src/codegen/arc_emitter/builtins/collections.rs—emit_set_union()viaori_set_unionruntime (sret) (verified 2026-03-29) - AOT Tests:
ori_llvm/tests/aot/sets.rs—test_aot_set_union(passing) (2026-03-01) (verified 2026-03-29)
- Evaluator:
-
Implement:
Set<T>.intersection(other) -> Set<T>— modules/prelude.md § Set [done] (2026-02-25) (verified 2026-03-29)- Evaluator:
ori_eval/src/methods/collections.rs— set intersection dispatch - Ori Tests:
tests/spec/types/set_methods/set_methods.ori— set intersection tests (verified 2026-03-29) - LLVM Support:
ori_llvm/src/codegen/arc_emitter/builtins/collections.rs—emit_set_intersection()viaori_set_intersectionruntime (sret) (verified 2026-03-29) - AOT Tests:
ori_llvm/tests/aot/sets.rs—test_aot_set_intersection(passing) (2026-03-01) (verified 2026-03-29)
- Evaluator:
-
Implement:
Set<T>.difference(other) -> Set<T>— modules/prelude.md § Set [done] (2026-02-25) (verified 2026-03-29)- Evaluator:
ori_eval/src/methods/collections.rs— set difference dispatch - Ori Tests:
tests/spec/types/set_methods/set_methods.ori— set difference tests (verified 2026-03-29) - LLVM Support:
ori_llvm/src/codegen/arc_emitter/builtins/collections.rs—emit_set_difference()viaori_set_differenceruntime (sret) (verified 2026-03-29) - AOT Tests:
ori_llvm/tests/aot/sets.rs—test_aot_set_difference(passing) (2026-03-01) (verified 2026-03-29)
- Evaluator:
-
Implement:
Set<T>.to_list() -> [T]— modules/prelude.md § Set [done] (2026-02-25) (verified 2026-03-29)- Evaluator:
ori_eval/src/methods/collections.rs— set to_list dispatch - Ori Tests:
tests/spec/types/set_methods/set_methods.ori— set to_list tests (verified 2026-03-29) - LLVM Support:
ori_llvm/src/codegen/arc_emitter/builtins/collections.rs—emit_set_to_list()viaori_set_to_listruntime (sret) (verified 2026-03-29) - AOT Tests:
ori_llvm/tests/aot/sets.rs—test_aot_set_to_list(passing) (2026-03-01) (verified 2026-03-29)
- Evaluator:
7C.5 Comparable Methods (min, max, compare)
Move from free functions to methods on Comparable trait.
-
Implement:
T.min(other: T) -> TwhereT: Comparable— modules/prelude.md § Comparable- Rust Tests:
ori_eval/src/methods.rs— min method tests - Ori Tests:
tests/spec/stdlib/comparable.ori - LLVM Support: LLVM codegen for min method
- LLVM Rust Tests:
ori_llvm/tests/comparison_tests.rs— min method codegen - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement:
T.max(other: T) -> TwhereT: Comparable— modules/prelude.md § Comparable- Rust Tests:
ori_eval/src/methods.rs— max method tests - Ori Tests:
tests/spec/stdlib/comparable.ori - LLVM Support: LLVM codegen for max method
- LLVM Rust Tests:
ori_llvm/tests/comparison_tests.rs— max method codegen - AOT Tests: No AOT coverage yet
- Rust Tests:
-
Implement:
T.compare(other: T) -> OrderingwhereT: Comparable— modules/prelude.md § Comparable [done] (2026-02-10) (verified 2026-03-29)- Rust Tests: Evaluator method dispatch — compare method tests
- Ori Tests:
tests/spec/traits/core/comparable.ori— 133 test occurrences (verified 2026-03-29) - LLVM Support: No LLVM codegen for compare method yet
- AOT Tests: No AOT coverage yet
-
/tpr-reviewpassed — independent review found no critical or major issues (or all findings triaged) -
/impl-hygiene-reviewpassed — hygiene review clean. MUST run AFTER/tpr-reviewis clean. -
Subsection close-out (7C.5) — MANDATORY before starting the next subsection. Run
/improve-toolingretrospectively on THIS subsection’s debugging journey (per.claude/skills/improve-tooling/SKILL.md“Per-Subsection Workflow”): whichdiagnostics/scripts you ran, where you addeddbg!/tracingcalls, where output was hard to interpret, where test failures gave unhelpful messages, where you ran the same command sequence repeatedly. Forward-look: what tool/log/diagnostic would shorten the next regression in this code path by 10 minutes? Implement improvements NOW (zero deferral) and commit each via SEPARATE/commit-pushusing a valid conventional-commit type (build(diagnostics): ... — surfaced by section-7C.5 retrospective—build/test/chore/ci/docsare valid;tools(...)is rejected by the lefthook commit-msg hook). Mandatory even when nothing felt painful. If genuinely no gaps, document briefly: “Retrospective 7C.5: no tooling gaps”. Update this subsection’sstatusin section frontmatter tocomplete. -
/sync-claudesection-close doc sync — verify Claude artifacts across all section commits. Map changed crates to rules files, check CLAUDE.md, canon.md. Fix drift NOW. -
Repo hygiene check — run
diagnostics/repo-hygiene.sh --checkand clean any detected temp files.
7C.6 Iterator Traits
PROPOSAL:
proposals/approved/iterator-traits-proposal.mdFormalize iteration with traits, enabling user types in
forloops and generic iteration.
-
Implement:
Iteratortrait (protocol implemented, formal trait definition pending) [done] (verified 2026-03-28) (verified 2026-03-29)trait Iterator { type Item @next (mut self) -> Option<Self.Item> }- Rust Tests: Evaluator — tested via spec test suite (verified 2026-03-29)
- Ori Tests:
tests/spec/traits/iterator/iterator.ori— core iterator protocol (.iter(), .next(), fused behavior, 7+ tests); 13 dedicated spec test files total [done] (verified 2026-03-28) (verified 2026-03-29) - LLVM Support: Works via iterator pipeline; AOT tests in
ori_llvm/tests/aot/iterators.rsdemonstrate LLVM codegen (verified 2026-03-29) - AOT Tests:
ori_llvm/tests/aot/iterators.rs— 25 tests covering iterator pipeline (verified 2026-03-29)
-
Implement:
Iterabletrait (protocol implemented, formal trait definition pending) [done] (verified 2026-03-28) (verified 2026-03-29)trait Iterable { type Item @iter (self) -> impl Iterator where Item == Self.Item }- Rust Tests: Evaluator — tested via spec test suite (verified 2026-03-29)
- Ori Tests:
tests/spec/traits/iterator/for_loop.ori— for-loop desugaring for list, range, str, set, map, Option [done] (verified 2026-03-28) (verified 2026-03-29) - LLVM Support: Works via for-loop codegen; AOT tests demonstrate LLVM codegen (verified 2026-03-29)
- AOT Tests:
ori_llvm/tests/aot/iterators.rs—test_for_over_iterator,test_for_over_range_iterator(verified 2026-03-29)
-
Implement:
Collecttrait (collect-to-list works, formal trait definition pending) [done] (verified 2026-03-28) (verified 2026-03-29)trait Collect<T> { @from_iter (iter: impl Iterator where Item == T) -> Self }- Rust Tests: Evaluator — tested via spec test suite (verified 2026-03-29)
- Ori Tests:
tests/spec/traits/iterator/collect.ori— collect_default_list [done] (verified 2026-03-28) (verified 2026-03-29) - LLVM Support: Collect-to-list (
ori_iter_collect) and collect-to-set (ori_iter_collect_set) both implemented (verified 2026-03-29) - AOT Tests:
ori_llvm/tests/aot/iterators.rs—test_list_iter_collect,test_iter_chain_collect(verified 2026-03-29)
NOTE:
tests/spec/traits/iterator/collect_set.orihas 6#skipmarkers (budget is 3 per tests.md) — type-directed collect to Set not fully implemented in evaluator -
Implement: Standard
Iterableimplementations [done] (verified 2026-03-28) (verified 2026-03-29)impl<T> [T]: Iterable— list iterationimpl<K, V> {K: V}: Iterable— map iteration (yields tuples)impl<T> Set<T>: Iterable— set iterationimpl str: Iterable— character iterationimpl Range<int>: Iterable— range iterationimpl<T> Option<T>: Iterable— zero/one element- Ori Tests:
tests/spec/traits/iterator/for_loop.ori— all iterable types tested (list, range, str, set, map, Option) [done] (verified 2026-03-28) (verified 2026-03-29) - LLVM Support: Works via AOT codegen for list, range, map, str iterables (verified 2026-03-29)
- AOT Tests:
ori_llvm/tests/aot/iterators.rs— list.iter()(2 tests), range.iter()(2 tests);ori_llvm/tests/aot/collections_ext.rs— map.iter()(2 tests), string.iter()viaori_llvm/tests/aot/strings.rs(3 tests) (verified 2026-03-29)
-
Implement: Standard
Collectimplementations (collect-to-list works; collect-to-set LLVM only) [done] (verified 2026-03-28) (verified 2026-03-29)impl<T> Collect<T> for [T]— collect to listimpl<T> Collect<T> for Set<T>— collect to set (LLVM__collect_setimplemented 2026-03-01)- Ori Tests:
tests/spec/traits/iterator/collect.ori— collect_default_list [done] (verified 2026-03-28) (verified 2026-03-29) - LLVM Support: LLVM codegen for standard Collect implementations — collect-to-list (
ori_iter_collect) and collect-to-set (ori_iter_collect_setvia__collect_setintercept) both implemented (2026-03-01) (verified 2026-03-29) - AOT Tests:
ori_llvm/tests/aot/iterators.rs—test_list_iter_collect,test_iter_chain_collect(collect to list via.iter().collect()) (verified 2026-03-29)
-
Implement:
forloop desugaring to.iter()and.next()[done] (verified 2026-03-28) (verified 2026-03-29)- Rust Tests: Evaluator — tested via spec test suite (verified 2026-03-29)
- Ori Tests:
tests/spec/traits/iterator/for_loop.ori— 16+ tests covering all iterable types [done] (verified 2026-03-28) (verified 2026-03-29) - LLVM Support: Works via for-loop codegen; AOT tests demonstrate LLVM codegen (verified 2026-03-29)
- AOT Tests:
ori_llvm/tests/aot/iterators.rs—test_for_over_iterator,test_for_over_range_iterator(for-loop over.iter()on lists and ranges) (verified 2026-03-29)
-
Implement: Iterator extension methods [done] (verified 2026-03-28) (verified 2026-03-29)
map,filter,fold,find,collect,countany,all,take,skip,enumerate,zip,chain- Also:
flatten,flat_map,cycle,for_each,join - Ori Tests:
tests/spec/traits/iterator/methods.ori— 50+ tests covering all methods with exact value checks and edge cases [done] (verified 2026-03-28) (verified 2026-03-29) - LLVM Support: Works via iterator pipeline; 25 passing AOT tests (verified 2026-03-29)
- AOT Tests:
ori_llvm/tests/aot/iterators.rs— 25 tests (0 ignored) covering map, filter, take, skip, count, any, all, find, fold, for_each, collect, zip, chain adapters/consumers via built-in iterator pipeline (verified 2026-03-29)
-
Implement: Extended Iterator methods (19 new methods) Proposal:
proposals/approved/iterator-extended-methods-proposal.md[approved] (2026-03-22)- Phase 1 — Reductions:
max,min,max_by,min_by,max_by_key,min_by_key,sum,sum_by,product,reduce- Registry: Add 10
MethodDefentries toori_registry/src/defs/iterator/mod.rs - Type checker: Method resolution in
ori_types - Evaluator: Consumer dispatch in
ori_eval/method_dispatch/iterator/consumers.rs - Ori Tests:
tests/spec/traits/iterator/reductions.ori
- Registry: Add 10
- Phase 2 — Adapters:
filter_map,take_while,skip_while- Registry: Add 3
MethodDefentries - Evaluator: New
IteratorValuevariants (FilterMap,TakeWhile,SkipWhile) - Evaluator:
next()dispatch inori_eval/method_dispatch/iterator/next.rs - Ori Tests:
tests/spec/traits/iterator/adapters_ext.ori
- Registry: Add 3
- Phase 3 — Index/Partition/Inspect:
step_by,inspect,position,nth,partition,rposition- Registry: Add 6
MethodDefentries - Evaluator: New
IteratorValuevariants (StepBy,Inspect) - Evaluator: Consumer dispatch for
position,nth,partition,rposition - Ori Tests:
tests/spec/traits/iterator/index_partition.ori
- Registry: Add 6
- Phase 4 — LLVM Codegen: AOT support for all 19 new methods
- LLVM Rust Tests:
ori_llvm/tests/aot/iterators_ext.rs
- LLVM Rust Tests:
- Phase 1 — Reductions:
GAP (identified 2026-03-29): The following iterator features have tests but are not tracked in this section.
-
Implement:
DoubleEndedIteratortrait — modules/prelude.md § DoubleEndedIterator (verified 2026-03-29)- Methods:
.rev,.last,.rfind,.rfold - Ori Tests:
tests/spec/traits/iterator/double_ended.ori,double_ended_methods.ori,double_ended_gating.ori— tests exist and pass (verified 2026-03-29) - AOT Tests: No AOT coverage yet
- Methods:
-
Implement: Iterator
.join(separator:)method (verified 2026-03-29)- Ori Tests:
tests/spec/traits/debug/join.ori— tests exist and pass (verified 2026-03-29) - AOT Tests: No AOT coverage yet
- Ori Tests:
QUALITY NOTE (2026-03-29): No negative tests (
#compile_fail) exist anywhere in this section. Missing coverage for: calling.sort()on non-Comparable type, calling.contains()with wrong element type, usingSet<T>where T is not Hashable, collecting to wrong type.
-
/tpr-reviewpassed — independent review found no critical or major issues (or all findings triaged) -
/impl-hygiene-reviewpassed — hygiene review clean. MUST run AFTER/tpr-reviewis clean. - Subsection close-out (7C.6) — MANDATORY before starting the next subsection. Run
/improve-toolingretrospectively on THIS subsection’s debugging journey (per.claude/skills/improve-tooling/SKILL.md“Per-Subsection Workflow”): whichdiagnostics/scripts you ran, where you addeddbg!/tracingcalls, where output was hard to interpret, where test failures gave unhelpful messages, where you ran the same command sequence repeatedly. Forward-look: what tool/log/diagnostic would shorten the next regression in this code path by 10 minutes? Implement improvements NOW (zero deferral) and commit each via SEPARATE/commit-pushusing a valid conventional-commit type (build(diagnostics): ... — surfaced by section-7C.6 retrospective—build/test/chore/ci/docsare valid;tools(...)is rejected by the lefthook commit-msg hook). Mandatory even when nothing felt painful. If genuinely no gaps, document briefly: “Retrospective 7C.6: no tooling gaps”. Update this subsection’sstatusin section frontmatter tocomplete. -
/sync-claudesection-close doc sync — verify Claude artifacts across all section commits. Map changed crates to rules files, check CLAUDE.md, canon.md. Fix drift NOW. - Repo hygiene check — run
diagnostics/repo-hygiene.sh --checkand clean any detected temp files.
7C.7 Debug Trait
PROPOSAL:
proposals/drafts/debug-trait-proposal.mdDeveloper-facing structural output, separate from user-facing
Printable.
-
Implement:
Debugtrait [done] (verified 2026-03-28) (verified 2026-03-29)trait Debug { @debug (self) -> str }- Rust Tests: Evaluator — tested via spec test suite (verified 2026-03-29)
- Ori Tests:
tests/spec/traits/debug/definition.ori— Debug trait definition and debug vs printable distinction [done] (verified 2026-03-28) (verified 2026-03-29) - LLVM Support: No LLVM codegen for Debug trait yet
- AOT Tests: No AOT coverage yet
-
Implement:
#[derive(Debug)]for structs and sum types [done] (verified 2026-03-28) (verified 2026-03-29)- Rust Tests: Evaluator — tested via spec test suite (verified 2026-03-29)
- Ori Tests:
tests/spec/traits/debug/derive.ori— derived debug on structs [done] (verified 2026-03-28) (verified 2026-03-29)
NOTE: NEEDS TESTS — only struct derive tested, no sum type derive test in derive.ori
- LLVM Support: No LLVM codegen for derive(Debug) yet
- AOT Tests: No AOT coverage yet
-
Implement: Standard
Debugimplementations [done] (verified 2026-03-28) (verified 2026-03-29)- All primitives:
int,float,bool,str,char,byte,void - Collections:
[T],{K: V},Set<T>(requireT: Debug) Option<T>,Result<T, E>(require inner typesDebug)- Tuples (require element types
Debug) - Ori Tests:
tests/spec/traits/debug/primitives.ori,tests/spec/traits/debug/collections.ori,tests/spec/traits/debug/wrappers.ori,tests/spec/traits/debug/tuples.ori— all types covered [done] (verified 2026-03-28) (verified 2026-03-29) - LLVM Support: No LLVM codegen for standard Debug implementations yet
- AOT Tests: No AOT coverage yet
- All primitives:
-
Implement: String escaping in Debug output [done] (verified 2026-03-28) (verified 2026-03-29)
"hello".debug()→"\"hello\""'\n'.debug()→"'\\n'"- Ori Tests:
tests/spec/traits/debug/escape.ori— 12+ tests: newline, tab, cr, backslash, quote escaping [done] (verified 2026-03-28) (verified 2026-03-29) - LLVM Support: No LLVM codegen for Debug string escaping yet
- AOT Tests: No AOT coverage yet
-
/tpr-reviewpassed — independent review found no critical or major issues (or all findings triaged) -
/impl-hygiene-reviewpassed — hygiene review clean. MUST run AFTER/tpr-reviewis clean. -
Subsection close-out (7C.7) — MANDATORY before starting the next subsection. Run
/improve-toolingretrospectively on THIS subsection’s debugging journey (per.claude/skills/improve-tooling/SKILL.md“Per-Subsection Workflow”): whichdiagnostics/scripts you ran, where you addeddbg!/tracingcalls, where output was hard to interpret, where test failures gave unhelpful messages, where you ran the same command sequence repeatedly. Forward-look: what tool/log/diagnostic would shorten the next regression in this code path by 10 minutes? Implement improvements NOW (zero deferral) and commit each via SEPARATE/commit-pushusing a valid conventional-commit type (build(diagnostics): ... — surfaced by section-7C.7 retrospective—build/test/chore/ci/docsare valid;tools(...)is rejected by the lefthook commit-msg hook). Mandatory even when nothing felt painful. If genuinely no gaps, document briefly: “Retrospective 7C.7: no tooling gaps”. Update this subsection’sstatusin section frontmatter tocomplete. -
/sync-claudesection-close doc sync — verify Claude artifacts across all section commits. Map changed crates to rules files, check CLAUDE.md, canon.md. Fix drift NOW. -
Repo hygiene check — run
diagnostics/repo-hygiene.sh --checkand clean any detected temp files.
7C.8 Section Completion Checklist
- All items above have all checkboxes marked
[ ] - Re-evaluate against docs/compiler-design/v2/02-design-principles.md
- 80+% test coverage, tests against spec/design
- Run full test suite:
./test-all.sh - LLVM Support: All LLVM codegen tests pass
-
/tpr-reviewpassed — independent Codex review found no critical or major issues (or all findings triaged) -
/impl-hygiene-reviewpassed — implementation hygiene review clean (phase boundaries, SSOT, algorithmic DRY, naming). MUST run AFTER/tpr-reviewis clean. -
/improve-toolingretrospective completed — MANDATORY at section close, after both reviews are clean. Reflect on the section’s debugging journey (whichdiagnostics/scripts you ran, which command sequences you repeated, where you added ad-hocdbg!/tracingcalls, where output was hard to interpret) and identify any tool/log/diagnostic improvement that would have made this section materially easier OR that would help the next section touching this area. Implement every accepted improvement NOW (zero deferral) and commit each via SEPARATE/commit-push. The retrospective is mandatory even when nothing felt painful — that is exactly when blind spots accumulate. See.claude/skills/improve-tooling/SKILL.md“Retrospective Mode” for the full protocol.
Exit Criteria: Collections and iteration working correctly
- Subsection close-out (7C.8) — MANDATORY before starting the next subsection. Run
/improve-toolingretrospectively on THIS subsection’s debugging journey (per.claude/skills/improve-tooling/SKILL.md“Per-Subsection Workflow”): whichdiagnostics/scripts you ran, where you addeddbg!/tracingcalls, where output was hard to interpret, where test failures gave unhelpful messages, where you ran the same command sequence repeatedly. Forward-look: what tool/log/diagnostic would shorten the next regression in this code path by 10 minutes? Implement improvements NOW (zero deferral) and commit each via SEPARATE/commit-pushusing a valid conventional-commit type (build(diagnostics): ... — surfaced by section-7C.8 retrospective—build/test/chore/ci/docsare valid;tools(...)is rejected by the lefthook commit-msg hook). Mandatory even when nothing felt painful. If genuinely no gaps, document briefly: “Retrospective 7C.8: no tooling gaps”. Update this subsection’sstatusin section frontmatter tocomplete. -
/sync-claudesection-close doc sync — verify Claude artifacts across all section commits. Map changed crates to rules files, check CLAUDE.md, canon.md. Fix drift NOW. - Repo hygiene check — run
diagnostics/repo-hygiene.sh --checkand clean any detected temp files.