Skip to content

Keep a returning arm out of the join's carried state - #174

Open
dcharlot65-openie wants to merge 3 commits into
mainfrom
cursor/early-return-join-dca1
Open

dcharlot65-openie wants to merge 3 commits into
mainfrom
cursor/early-return-join-dca1

Conversation

@dcharlot65-openie

@dcharlot65-openie dcharlot65-openie commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Fixes the join in issue 163. A returning arm no longer adds its return to the carried slots. The return stays a return, distinct from break and from continue. The gates are unchanged.

Under section 13, construct(schedule(F)) equals F byte for byte for every form this change admits. The six return tests assert those bytes.

Main at 86b8efcf (PR 154) is merged in with an ordinary merge commit 07afb055. PR 160 and PR 171 are still open. Scope has early and does not yet have carrying.

Root cause

On main 9ef5c387, finish_if in spec/checker/src/form/bridge.rs seals End::Ret by pushing the return value, then ω when the region has ω. The arm that falls through pushes the carried slots. For rt.text.isdigit and rt.text.find those slots are ω alone, so the join expects 1 output. The returning arm presents 2 values and the fall-through arm presents 1.

Measured on that revision, before this change:

  • rt.text.isdigit: join_flag false, needs_w true, vars empty, e0 is Ret, e1 is Fall, outputs 2 and 1 for 1 output.
  • rt.text.find: the same join, with the arms swapped, outputs 1 and 2 for 1 output.

What changed

The carried slots are taken from arms that fall through. A returning arm passes those slots through and does not place the return among them. The return is two further outputs of the same branch: a continue flag that is false on the returning arm, and the return value. A break still uses its own flag. join_flag together with Ret stays refused. The gate is not edited.

A loop carries that channel out. The function return selects the early value when the flag is false, and the caller's own return when the flag is true.

The schedule of that channel has to construct back to the same form.

  • The branch dummy for a return flag was the literal false. The returning arm captured that dummy, so the rebuilt measure had no literal false in the arm and FG8 refused it. The dummy for that flag is now a bool the arms do not capture, and the arm builds its own literal. A break flag is output 0 of a branch that also carries another value. That dummy stays the literal false, so those schedules stay as they were.
  • A literal the parent built, which an arm returns, was inlined into the arm. rt.text.find rebuilt -1 inside the selecting arm. The schedule now binds that literal with a let in the parent, and the arm returns the local.

Overlap with PR 160 and PR 172

This change edits schedule_branch. PR 172 also edits that function: it lifts a non-bool capture the arms return, and it builds a fresh bool inside an arm. The two lifts meet in the same function. If PR 172 lands on main before this branch is green, an ordinary merge keeps both. Do not rebase. The return-flag dummy stays on this branch. PR 172's fresh bool in ensure_lit stays on that branch. One parent literal should be one let.

The overlap with PR 160 is the Scope value in spec/checker/src/form/bridge.rs. PR 160 adds carrying. This branch adds early. The literals are the same sites, including the scopes inside finish_if. If PR 160 lands, an ordinary merge keeps both fields.

Census

Command, from spec/checker:

cargo test --release --test break_fg8_witness corpus_baseline_on_50294e05 -- --test-threads=1

The checker and the examples are the same bytes on 9ef5c387 and on main 86b8efcf. The command passed on main 86b8efcf (678.40s) and on this head (502.55s). The pins are unchanged.

main 86b8efcf this head
programs 60 60
whole 2 (09_generics, 35_nested_if) 2 (same)
floor 5 5
semantic 0 0
construct alone 18 19 (33_in_operator constructs)
root break 18 18
root FG8 33_in_operator 33_in_operator
root defect 06_option, 07_error_union, 20_strings 07_error_union
root loop 50_iterators, 55_rcedb those two, plus 06_option and 20_strings
whole-module defect 07_error_union, 20_strings, 33_in_operator 07_error_union, 20_strings
schedule FG8 43_simd_lanes 33_in_operator, 43_simd_lanes

51_refined_input.rce leaves the defect set. Census line 145 is whole break,exit and roots break.

33_in_operator.rce still refuses at the module with FG8, so it is not on the syntactic floor. Its root set was FG8,round-trip and is now FG8, because the rt.text.find closure constructs back to the same bytes. 07_error_union still refuses: the root tag stays defect, and the whole-module set stays defect,exit,loop. The rt.text.isdigit closure constructs back to the same bytes. 06_option and 20_strings move from a root defect to loop because construction reaches the next refusal. They do not become whole. The form-bridge header counts stay programs 60, floor 5, semantic 0, whole 2.

Checks run here

  • cargo test --release --test break_fg8_witness corpus_baseline_on_50294e05 -- --test-threads=1 (passed, 502.55s)
  • cargo test --release --test form_bridge examples_are_covered_or_require_change (rewrote the 33_in_operator root set, then passed)
  • cargo test --test break_fg8_witness -- --skip corpus_baseline (17 passed)
  • cargo test --test form_bridge -- --skip examples_are_covered (38 passed)
  • python3 scripts/check-removed-paths.py and python3 scripts/check-flags.py (passed)

Not merged. Not deployed.

Open in Web Open in Cursor 

cursoragent and others added 3 commits November 13, 2026 19:00
A join sealed the return value onto the returning arm and the carried
slots onto the arm that falls through, so the widths differed. The
return is now its own channel, and the carried slots come from the
arms that fall through. Return stays distinct from break and from
continue.

Co-authored-by: David Charlot <dcharlot65-openie@users.noreply.github.com>
Main moved when PR 154 landed. This keeps the return channel on the current tip.
Co-authored-by: David Charlot <dcharlot65-openie@users.noreply.github.com>
…ytes.

A returning arm's false flag was rebuilt as a capture of the branch dummy, and the measure then failed FG8. That dummy is now a bool the arms do not capture, so the arm keeps its own literal. A parent literal that an arm only returns stays a let in the parent. The return tests assert construct(schedule(F)) equals F.

Co-authored-by: David Charlot <dcharlot65-openie@users.noreply.github.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants