Repository navigation
[0.5.0] #279: a fallible loop's ends are in its function's tail (RB-21) - #300
Conversation
…ible loop (#279) R3 first: the row RB-21 (§17.13, §17.16), its scenario in rust-backend.feature, conformance_rb_21, and the committed project tests/rust-backend/loop-ends, whose Main is the module of #279 as filed and whose Looped ends its loop with a call of a function that is itself a loop. The case lowers both roots, renders them in rust-std, and expects the loop to end with the callee's result as it is; it plants the call bound before the end and the end dropped, runs the packages under rustc beside the calculus evaluator, and under Lean exports and replays both roots. Red on release/v0.5 2959a4d for the issue's reason: LoopEnds.Main.run: no rendering in rust-std: arithmetic: the fallible call of f2 does not propagate its overflow Register 443 -> 444; README count and the RB range (RB-15..RB-20 are held by the v0.4 line and open PRs, so this is RB-21). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A function whose self calls are all tail calls is rendered as a loop (RB-14): a tail self call continues it with Ok of the next state, and every other tail value e ends it as Err(e), so the loop breaks with e. When the function is fallible and the loop is its value, e is what the function returns, so a call of another fallible function there returns that function's result as it is. rust::validate checked the loop body with tail = false, so it refused the call (LLB6005) and the module of #279 had no rust-std rendering. - calculus/rust/validate.rs: the operand of each Err at a tail of such a loop is checked as the function's tail; every other position of the body as before. - bootstrap RustValidate (BS-05): Cx gains ends; endArgsC checks those operands as the tail. Three hand-built loop crates (37) and a seventeenth plant; counts 409 (168) / 272 (49). The old end check looked only at an operand's outer construct, so a fallible loop ending with Err of a branch of two units was accepted; it is now refused by both (BS-05 run 153). - SPEC §17.16 (failure typing) and §17.23 (Crate data, BS-05 counts), VERIFICATION (RB-21 entry with two plants, BS-05 counts and plant 17), CHANGELOG. - rust_renderer moves, and with it the language-1.2 compiler-semantics ID 5262e5b4c8b5 -> 138ffb6279c2: 241 locks relocked, records regenerated with check-calculus, check-fixtures, check-golden, check-production-export and verify-examples (without uor-atlas, a language-1.0 project). conformance_rb_21 and conformance_bs_05 pass locally; RB-21 includes the rustc differential and, under Lean 4.32.1, export and replay. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ail-call CHANGELOG.md conflicted again on the unreleased entries (#288 moved the AU-14 bullet); both sides are kept, the line's before RB-21. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…279) `just vv (rest)` on 6085271 failed eight cases. `rb_02`..`rb_05`, `rb_07`, `gc_01` and `gn_01` compared the 351 committed packages, provenance files and negative manifests under compiler/rust with their generator: their `sources` named the compiler build's semantic ID before the identity move (7a08f62b…) while compiler/expected/build/manifest.json names the build after it (3d5f7b04…), because `check-calculus --write` ran before the compiler record was regenerated. `check-calculus --write` rewrites them; nothing else in a record changes. `ns_01` found `spec/src/IdsRB.lex.tex` not canonical: `lexlean fmt` adds the blank line before `rb21`. With #288 (RP-17) on release/v0.5 the register holds 446 IDs: README's count sentence and SPEC.md's total (`validate-model --write`) say so. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Round on this branch: it is merged with Merges (merge commits, no rebase)
Both times only Why
Both causes are in this PR's change, not on the line, where both the build record and the Rust records name Fix:
Local results on
CI on The PR stays a draft. The question for @afflom in the description (fallible closure applications at a loop's end) is still open. |
…ail-call The line took PC-01 and PC-02 (register 447); RB-21 keeps its number, the register is 448. README and SPEC.md state 448, the CHANGELOG bullet ends "Register 448". CHANGELOG.md and VERIFICATION.md merged with both sides, the line's first. The spec lock keeps this change's compiler-semantics ID (138ffb62...) with the line's project config hash (it now lists IdsPC). The performance corpus is a language-1.2 project, so its lock, build manifest and oracle files regenerate under the moved compiler-semantics ID; the calculus records, the verification records and the golden oracles are rewritten for it. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Merged
Local results at ff7fd46: |
…ail-call The line took PF-24 (register 448); RB-21 keeps its number, the register is 449. README, SPEC.md and CONFORMANCE.md state 449, the CHANGELOG bullet ends "Register 449". CHANGELOG.md merged with both sides, the line's first. #296 moved the language-1.2 compiler-semantics ID, and this change's renderer digest moves it again, so every lock, calculus record, fixture expectation, verification record, golden oracle and production export is regenerated by the writers from the merged tree; the Atlas is not regenerated. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Merged
Local results: |
|
Maintainer review of What checked out. The defect is as #279 states it: Your question, One push, then I merge on green:
Say the head here when it is up; the gate reruns on it and I merge by merge commit. Generated by Claude Code |
|
One more item for the same push, found while ruling on #116: Generated by Claude Code |
|
Maintainer, after the fact: this PR was merged at The merged head is sound (the gate was green and the review found nothing blocking), so no revert this time. What it owes now lands as one small follow-up PR on
None of it moves the identity. Say the PR number here; I review and merge it. Generated by Claude Code |
|
Maintainer: the follow-up PR asked for above is withdrawn (owner's direction: no new PRs or issues outside v0.4 until the tag). The Generated by Claude Code |
Fixes #279. Targets
release/v0.5, merged with its headbde798bd6(#285, #287).The rule
A function whose self calls are all tail calls is rendered as a loop (§17.16,
RB-14). A tail self call continues the loop withOkof the next state; every other tail valueeends it asErr(e), so the loop breaks withe. When the function is fallible and the loop is its value,eis what the function returns. The operand of each suchErris therefore in tail position.The lowering already rendered the module of #279 that way (
Err::<u64, R<u64>>(f2(v1)), thenbreak done). Butrust::validatechecked the whole loop body withtail = false, soChecker::callrefused the call withLLB6005. The validator now checks the operand of eachErrat a tail of such a loop as the function's tail, and every other position of the body as before.LexLeanBoot.RustValidate(BS-05) mirrors this:Cxgainsends, andendArgsCchecks those operands withtail = true.One behaviour change beyond the issue: the old end check looked only at an operand's outer construct, so a fallible loop ending with
Err(if … { () } else { () })was accepted. Checking the operand as the function's tail refuses it, in the oracle and in the module alike. No rendered crate has that shape (all 223 are still accepted). One hand-builtBS-05crate does (run 153).Rows
RB-21 (new, §17.13, §17.16). The project
tests/rust-backend/loop-endsholds the module of Production: a looped fallible function cannot tail-call another fallible function (LLB6005) #279 as filed and a variant whose callee is itself a loop. The case checks that both:rust-stdand end their loops with the callee's result as it is;It also plants the call bound before the loop's end, and the end dropped; both are refused.
BS-05 (counts). 3 hand-built loop crates (37): the issue's shape is accepted, and both plants are refused. A seventeenth bootstrap plant. Vectors are 409
validateCrate(168 refused) and 272correspondCrate(49 refused), 681 in all; evaluator vectors are 386 + 249.Register 444 → 445 after the merge with AU-14. README count,
RB-01..RB-21.Plants (all detected locally)
LoopEnds.Main.run: no rendering in rust-std: arithmetic: the fallible call of f2 does not propagate its overflow(the issue's own error).... the value a fallible function returns, construct:ok, is not a fallible value.ends := gated}) body gated)→ends := false}) body false)): run 153, where the planted module givesok ()and the oracle refuseslit:unit.Identity
validate.rsis a renderer source, sorust_renderermoves, and with it the language-1.2 compiler-semantics ID (5262e5b4c8b5…→138ffb6279c2…). All 241 language-1.2 locks were relocked; only thecompiler_semanticsline changes. The records were regenerated withcheck-calculus,check-fixtures,check-golden,check-production-exportandverify-examples.uor-atlas, a language-1.0 project the move does not touch, was left out. Of the 2,266 changed files, the 1,029 deletions are hash-named audit files, each renamed with a successor.Run locally
conformance_rb_21(208 s),conformance_bs_05(952 s: 681 + 4,000 rustc runs, the evaluator, 17 plants),conformance_rp_07,rp_11,ns_07,au_14;validate-model,validate-spec-links,check-test-inventory, rustfmt, clippy-D warningsonlexleanandrepo-conformance,lexlean fmt --check.Not verified locally
The full
bddsuite and theuor-atlasrecords; CI carries them. The other open PRs onrelease/v0.5that change the register or move the 1.2 identity (#286, #288, #289, #290, #295, #296) will conflict with this branch on counts and records. Whichever lands second regenerates.Numbering
RB-15..RB-17 are on
release/v0.4, RB-18 is in #228/#238, RB-19 in #255, and RB-20 in #295, so this row takes RB-21.Question for @afflom
A fallible closure application (
Expr::Apply) at a loop's end has the same shape as the call fixed here.apply_typesstill checks a loop body withtail = false, so I expect it to be refused (not tested). #279 is about calls, so I left applications alone. Should they be in this PR, in a follow-up, or not at all?🤖 Generated with Claude Code