Repository navigation
D142 and D143: a pipeline iterates a sequence, a slice has iter(), a self-calling function infers its return (#2534, #2535) - #2542
Merged
Merged
Conversation
added 2 commits
October 21, 2026 20:47
…ter(), and a self-calling function infers its return from the other paths Eric ruled both briefs (#2534, #2535) yes, with one amendment each; the quicksort as he wrote it is the fixture for the pair, annotated and not. D142 (§13.5): a sequence on the left of `|>` iterates by the rule `for` uses — when the stage is no method of the value but is one of the iterator its `.iter()` returns, Sema records the inserted `.iter()` (pipeline_implicit_iter, the for_iter_* records keyed by the pipeline node) and MIR calls it, the stage reading the iterator wherever it read the piped expression. A slice has `iter()`: std's `slice_iter` (`SliceIter[T]`, since no `impl` can name a slice type), for the spelled call, `for`, and `|>`. Collecting views of value elements builds values (D111, D139): `iter_collect_views` did already; a collection literal's elements with no outer demand now follow the same owned-demand rule, so `[pivot]` with `pivot: &isize` is a `List[isize]`, never borrows into the matched place. D143 (§9.1): a package-local function without a return type whose body calls itself is checked twice. A first, silent pass with its own calls open (`Never`; `++` now takes the other side's type from a Never operand as `+` did) lets the other paths decide the type; the second pass checks the body under that type as its demand (`[] => []` takes it), and a self-call path that disagrees is named with the decided type (a disagreement the first pass sees in an arm join is reported after it the same way). Every path a self-call: "write `->`". A `pub fn` declares its return type (Law 6). Mutual recursion with neither type written is refused naming the cycle. Today's "returns Unit" for the self-call was the compiler choosing a type for an arm, which D43 forbids. Spec words in §13.5 and §9.1; decision records D142, D143.
The ceremony audit flags the written `-> str` on the recursive json_to_string once D143 infers a self-calling function's return from its other paths; the example tracks the spec (Eric, 2026-09-22).
Contributor
Author
|
Battery GREEN on ea9eaa8: gate, uat and battery-checks under the pinned seed, logs in out/battery/. |
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.
D142 and D143 (#2534, #2535), as ruled 2026-10-21
Eric's quicksort, as he wrote it, is the fixture for the pair: with its return type (
behav_d142_pipeline_over_sequence.w) and without (behav_d143_recursive_inferred_return.w).D142 (§13.5). A sequence on the left of
|>iterates by the ruleforuses; a slice hasiter()(std'sSliceIter[T]throughslice_iter, since noimplcan name a slice type); collecting views of value elements builds a list of the values (D111 + D139), which the literal[pivot]with a viewpivotnow follows too. Sema records the inserted.iter()under the pipeline node with the samefor_iter_*records aforloop uses, and MIR calls it before the stage.D143 (§9.1). A package-local function with no return type that calls itself: a first silent pass with its own calls open (
Never) lets the other paths decide the type; the second pass checks the body under it as the demand, and a self-call path that disagrees is named with the decided type. The three limits Eric stated: apub fndeclares its return type (Law 6); the re-check must agree, naming the arm; mutual recursion is written, naming the cycle. Fixtures:err_d143_every_path_recursive.w,err_d143_pub_recursive_declares.w,err_d143_mutual_recursion.w,err_d143_self_call_path_disagrees.w.Decision records D142 and D143 in
docs/meetings/, index updated; spec words indocs/spec/013_iteration.md(§13.5) anddocs/spec/009_functions.md(§9.1).Closes #2534. Closes #2535.