Repository navigation
samples: require the selected value in match providers and pin the joined wording - #8512
Merged
Merged
Conversation
A helper that reads the value a match selected was refused with "cannot prove requires contract for call" in three situations where the fact it needs is established. The checker now carries that fact in each of them, and the twin programs that select the other value are still refused. A private helper that omits `requires` may rely on what every caller proves. The checker already told such a helper what a record field behind a reference holds. It now also tells it what a reference to one scalar holds, so `apply(chosen: @i64, ...)` called with a reference to 17 can pass that reference to a reader that requires `$place == 17`. A provider's conformance witness reads the bodies of the helpers the provider calls. It checked them for every possible input, while the root checked them under the conditions their callers establish, so a helper the root accepted was refused in the witness. The witness now treats a helper as private when the root did, and stage 06 infers its inputs from the calls the witness contains. A join's predicate lists what each arriving edge knows. An edge whose own facts contradict each other, such as the `false` arm of a match on a local bound to `true`, used to stay in that list without its contradiction, so the join could not rule the arm's value out. Such an edge now adds no alternative. Its arrival must still prove the predicate from the same contradiction. Samples: the `target_body` programs of match_primitive_local_origin and match_join_place_read now state the requirement on the provider trait and its implementations, as the spec requires of an implementation and as match_reference_referent already does. Eighteen reject twins pin the wording the compiler prints today. Agent: Claude Code | Model: claude-fable-5-2 | Effort: low | Tokens: unavailable in (unavailable cached), unavailable out | Steps: unavailable | Time: unavailable | Steers: 0
…-wxvuj1 # Conflicts: # source-rust/subsystems/compiler/source-to-psi/pipeline/06_lowered-program-to-checked-program/src/control_flow/joins/description.rs
Agent: Claude Code | Model: claude-fable-5-2 | Effort: low | Tokens: unavailable in (unavailable cached), unavailable out | Steps: unavailable | Time: unavailable | Steers: 0
…-wxvuj1 # Conflicts: # TASKS.md # source-rust/subsystems/compiler/source-to-psi/pipeline/06_lowered-program-to-checked-program/src/control_flow/joins/description.rs
…-wxvuj1 # Conflicts: # TASKS.md # source-rust/subsystems/compiler/source-to-psi/pipeline/05_prepared-typed-trees-to-lowered-program/src/read/bodies/machine/components.rs # source-rust/subsystems/compiler/source-to-psi/pipeline/06_lowered-program-to-checked-program/src/storage/places/bindings/call_observations.rs # source-rust/subsystems/compiler/source-to-psi/pipeline/06_lowered-program-to-checked-program/src/tests/calls/boundaries/provider_supplies.rs
…-wxvuj1 # Conflicts: # TASKS.md # source-rust/subsystems/compiler/source-to-psi/pipeline/06_lowered-program-to-checked-program/src/calls/entry_inputs/entry_inputs.rs # source-rust/subsystems/compiler/source-to-psi/pipeline/06_lowered-program-to-checked-program/src/tests/calls/inputs/entry_inputs.rs
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.
Requested by Jarod · project thread
A helper that reads the value a match selected was refused with "cannot prove requires contract for call" even where the program establishes the fact the read needs. While this PR was open, main landed the same three checker changes it made (#8472 crosses a referenced scalar into a private helper and gives a provider's witness the helper's inferred inputs; #8454 drops a join arm a literal subject rules out). This PR now keeps main's code and adds the tests, sample fixes and expectation updates that finish the four families. All 74 samples in them now pass.
Sample changes
match_primitive_local_origin/target_bodyandmatch_join_place_read/target_body(and their twins) declared a provider trait and implementations with norequires, then read a value that only one caller makes 17. The spec says an implementation checked against a declared requirement never gets inferred narrowing, so the checker is right to refuse them. I addedrequires chosen == 17(andrequires chosen.kept == 17) to the requirement and both implementations, asmatch_reference_referent/target_bodyalready does. This edits the sample programs, not only their expectations. The twins still differ from the positives in the same one place.match_reference_referentreject twins pinned the retired wordingmatch choose() { ... } == 17. They now pin$joined == 17and the fact$place == 17. The nested twin namespickandentry, the machine and state that make the call.Tests
Three accept/refuse pairs in
lowered-program-to-checked-program:a_private_helper_learns_the_scalar_behind_a_reference_argument,a_join_ignores_the_arm_a_literal_subject_rules_out, anda_provider_passes_its_requirement_to_a_private_helper(a shared-reference case beside main's@mutableprovider test). Theentry_inputs.rsheader now says a referenced scalar crosses.TASKS.md: the requires-contract sector drops from 40 to 14 samples.Gate: RC-SOURCE-SEMANTICS | a helper can read a match-selected value when its caller, its provider's requirement, or a literal match subject establishes the required fact
Spec: wiki/spec/language/state_contracts.md#private-entry-inference, wiki/spec/language/state_contracts.md#unreachable-branches, wiki/spec/terminal-psi/fact_validity.md
Proof:
omega --check --target linux_x86_64on all 74 samples of the four families after merging main at 6ade312: every positive accepted and every twin refused with its pinned text; the four new or touched tests pass | the fulllowered-program-to-checked-programlib run was killed for memory on this host, and five tests that touch none of this PR's files failed in it (this PR changes no non-test code there beyond a doc comment)Agent: Claude Code | Model: claude-fable-5-2 | Effort: low | Tokens: unavailable in (unavailable cached), unavailable out | Steps: unavailable | Time: unavailable | Steers: 0
Generated by Claude Code