Skip to content

Design note: -mm=own deferred releases (draft for discussion) - #1134

Merged
ASDAlexander77 merged 1 commit into
mainfrom
own-deferred-release-design
Dec 5, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
own-deferred-release-design

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Design note only, no code: docs/superpowers/specs/2026-12-05-own-deferred-release-design.md.

Proposal: when a release in the same function conflicts with a live local borrow, the compiler moves the release to the end of the borrow instead of refusing the program. The unlink still happens where the program says. Only the free is delayed: to a function-local temporary, or to a deferral list when the release is in a loop. Delaying a release can't cause a use-after-free; it only keeps memory alive longer.

What's in the note:

  • Conditions: the release ends only borrows whose extent is known, and it waits for the latest of them. A call that may free is still an end, so it is still refused. Every way out of the extent releases what was deferred, including exceptions; that last point rests on an assumption the note still has to check.
  • Classification: the 18 refused scratch cases from TSLANG 235, sorted by hand. One shape is confirmed accepted (r2 / own_err_walk_const_head_cut) and one is unverified (r3). Frees inside a callee and moves of the borrowed object stay refused.
  • Decisions for the user:
    • the language rule change;
    • default or opt-in;
    • the order against --own-fallback=count;
    • what to do with loops that consume the list as they walk, where deferring would grow memory with the list.
  • Phase 2 sketch: a moved local becomes a borrow of the place it moved into.

🤖 Generated with Claude Code

…nstead of refusing (draft for discussion)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit e329414 into main Dec 5, 2026
0 of 8 checks passed
@ASDAlexander77
ASDAlexander77 deleted the own-deferred-release-design branch December 5, 2026 15:47
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.

1 participant