Repository navigation
D103 at every demand site; D140 impl signatures from the trait; D141 None joins T into Option[T] - #2536
Merged
Conversation
added 6 commits
October 21, 2026 00:19
…lection literal's elements (D103, the missing demand sites) D103 rules the conversion at every demand site; the implementation had arguments, fields, annotated bindings, assignments, returns and if/match arms, and lacked a block's tail under an Option return (the mismatch branches only Ok-wrapped a Result) and a collection literal's elements under a known Option element type. Both now call value_to_option_at_demand before the mismatch. One fixture per demand site (behav_d103_site_*). D140 and D141 are recorded in the decision log (ruled 2026-10-21); their implementation follows.
…CE on a cast or ++ at the return)
check_return recorded the converted Option on the expression; MIR then
lowered a cast or a `++` at the Option ("unsupported cast in MIR" on
`return raw.unwrap() as Kind`, and on `return s ++ "!"` under Option[str]).
The record is the conversion (value_to_option_nodes); the node keeps `T`,
and check_body_explicit_value_results reads the record before comparing.
Fixture: behav_d103_site_return_cast.
…p, tools/sweep_some_at_option_demand.w) Compiler-driven, never textual: the tool reads Sema's ceremony record (`COMPILER check ROOT.w --ceremony-census`, pattern some-at-option-demand, with byte spans) and removes a `Some(x)` only where Sema proved the demand is Option[T] and x: T -- the condition D103 inserts it under -- so `return Some(None)` under Option[Option[T]] is never touched; migrated corpora (D112) and anything else are listed, not edited. Over src/main.w's program: 9 sites in lib/std and src removed; the remaining src tail and return sites that need this layer's Sema (the tail conversion, the return-record fix) keep their Some until a seed carrying it is pinned, since the pinned seed compiles src.
…ten one must match
Ruled by Eric 2026-10-21. collect_fn_decl resolves an omitted parameter
type of a trait impl's method from the trait's declaration, instantiated
for the impl (trait_impl_param_type: the same name, else the same
position among the non-receiver parameters; Self is the impl type); a
written type that differs is an error naming both. An untyped parameter
of any other fn is an error too -- it used to reach codegen as a missing
FnAbi type ("cannot lower FnAbi parameter"). The return half existed
(trait_impl_method_contract, #652); a generic impl's return is #2531.
Spec section 11.1; fixtures behav_d140_* (the static method is named
`unit`, #2520) and err_d140_*.
…d tail precedes the leaf checks Ruled by Eric 2026-10-21 (amends D43, carves the case out of D103): where a return type is inferred, a `None` return, tail or arm beside a `T` joins to Option[T] (none_value_join, before compatibility, since a bare None is compatible with every Option); `None` beside an `Option[U]` is written (cannot infer: write the return type). Once the inferred type is that Option, every T leaf converts (convert_body_values_to_option after inference; a joined if/match arm converts at the join and the per-arm acceptance reads the record). A bare `None` is typed at Option's own declaration (is_bare_none_type). Also: the tail of a function body converts to a demanded Option before any leaf check reads the record -- a specialization's body is checked with no return demand, so `&self.list[i]` under `-> Option[&T]` in ListIter.next failed Sema in every program that touched it (seen as `xs.iter() |> max() ?? 0` inferring Unit). ListIter.next now reads `self.idx += 1` and `&self.list[i]`. Spec sections 9.1 and 4.9a; fixtures behav_d141_* and err_d141_*; 210 behavior fixtures green.
…ed (audit:resolution read the node type) The operand audit compared the node's own Sema type (T) with the MIR operand (Option[T]) and reported four std tails as disagreements (cstr_option_from_ptr, Regex.capture_index, Regex.captures_at, Captures.get). The conversion is Sema's own adjustment, like the splat and lane-conversion records beside it: the recorded Sema type is the demanded Option.
Closed
ehartford
marked this pull request as ready for review
October 21, 2026 20:53
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.
D103 at every demand site, D140 and D141
Eric's review of
mut fn next() -> Option[&T]in the newListIterbody asked whySome(&self.list[i])had to be written. D103 already rules it ("a value converts toOption[T]at an Option demand"), so the missing sites are bugs, and two questions it raised became rulings (blessed 2026-10-21):returnkeeps the node's own type (an ICE onreturn x as Kindand on++at the return).tools/sweep_some_at_option_demand.wis the compiler-driven sweep: it asks--ceremony-censusfor thesome-at-option-demandspans and removes exactly those (a regex sweep had changedSome(i) =>patterns and would silently changeSome(None)underOption[Option[T]]). The sites the pinned seed cannot yet compile withoutSome((tails and returns insrc/) keep it until the next seed.trait_impl_param_typein SemaDecl.w maps by name, else by position among the non-receiver parameters.TandNonejoin toOption[T]. A branch already of typeOption[T]besideNonedoes not join (Option[Option[T]]would be a second meaning) and the type must be written. The conversion never solves a type variable.Spec words: §4.9a (sites, D141 pointer), §9.1 (D141), §11.1 (D140); decision records D140, D141 in
docs/meetings/.Fixtures:
behav_d103_site_{tail,return,arm,binding,assign,arg,field,element,if_tail,return_cast}.w,behav_d140_impl_signature_from_trait.w,err_d140_written_type_must_match_trait.w,behav_d141_inferred_return_none_join.w,err_d141_none_beside_option_is_written.w.Filed on the way: #2520 (trait-name collision), #2524 (
??on a view of Option), #2525 (a regex literal starting with=), #2531 (generic trait impl with an omitted return has no demand), #2532 (D93 chaining of[]by use).