Skip to content

Drop an owned catch sum on the arm that does not read it - #179

Open
dcharlot65-openie wants to merge 1 commit into
mainfrom
cursor/tuples-w3-use-it-1893
Open

dcharlot65-openie wants to merge 1 commit into
mainfrom
cursor/tuples-w3-use-it-1893

Conversation

@dcharlot65-openie

Copy link
Copy Markdown
Contributor

fn use_it in 22_tuples.rce schedules again. The handler of divmod(17, 5) catch (0, 0) builds its own pair and does not read the catch sum. The success arm does. W3 is unchanged.

Root cause

On main 86b8efcf the schedule of fn use_it refused with:

defect: the schedule is not well formed: ... W3: the paths that meet after an if hold different owned values ({1: Live, 3: Dead, 4: Live} and {1: Dead, 3: Dead, 4: Live})

The locals are the catch sum (v1), the dummy tuple consumed by the output var (v3), and that var (v4). The core is:

  • tag 0 reads the sum with sum.get and stores the pair
  • tag 1 builds (0, 0) and does not mention the sum
  • the unreachable tag arm drops the sum

The inner if therefore meets with v1 live on the handler and dead on the proof arm. The Form already ends an unused owned value when the region ends. The schedule wrote that drop only on the proof arm.

What changed

When both arms fall through, an owned value that one arm has moved is dropped on the arm that still holds it. A value both arms still hold stays, because the parent uses it after the branch. The proof arm drops only the values the falling real arm has already moved. It no longer drops a capture that arm still holds. W3, FG7, FG8, and C7 are not edited.

A handler that does not read the sum round-trips: construct(schedule(F)) == F, and the scheduled core returns 5. fn use_it now schedules and returns 5 (3 + 2). Its closure still differs in bytes because fn divmod already did, on this same base.

Overlap

PR 160 records this W3 split as still open and does not change it. This branch does not restructure a non-loop block break. Both branches edit the proof arm in schedule_branch; the drop set is the change here.

PR 174 keeps a returning arm out of the join. This branch does not change that seal.

Census

main 86b8efcf head b0d69f04
22_tuples.rce whole defect round-trip
22_tuples.rce roots defect,round-trip round-trip
whole-module round-trip 14 15
whole-module defect 2 1
program-root round-trip 16 17
program-root defect,round-trip 1 0

whole stays 2. The syntactic floor stays 5. fn use_it is not whole: fn divmod is still a byte mismatch.

Checks

Release, on this head:

  • break_fg8_witness: 14 passed
  • form_bridge: 39 passed
  • one_lower: 8 passed
  • typed_tree: 2 passed
  • check-flags.py: 0
  • check-removed-paths.py: 0

Not merged. Not deployed.

Open in Web Open in Cursor 

fn use_it catches divmod into a pair. The success arm reads the sum and the handler builds (0, 0), so one path left the sum live and the unreachable tag arm dropped it. W3 refused the schedule. A falling arm now drops an owned value the other falling arm has already moved, and the proof arm drops only those values, so both paths meet with the same ownership.

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