Skip to content

typecheck: track arena_alloc pointer domain to its arena argument - #826

Merged
godofecht merged 2 commits into
mainfrom
feat/690-arena-domain-tracking
Sep 5, 2026
Merged

godofecht merged 2 commits into
mainfrom
feat/690-arena-domain-tracking

Conversation

@godofecht

@godofecht godofecht commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Progresses #690.

Harvested from completed Jules session 11936246528485187102. The return of arena_alloc(a, size) carries the borrow root of a, so storing an arena pointer into longer-lived storage is rejected as an LD1 domain escape. malloc is deliberately unchanged in this increment.

Original local validation on the harvested head: tests/unit/test_lifetime_domains.py passed 46 tests, including the flipped former-gap test.

Current maintenance status (2026-08-31): GitHub currently reports the PR mergeable, but the branch was cut from d65c3e59… and its validation predates the fixed-point/callback ABI/release-doc changes now on main.

Exact next action: refresh the branch against current main locally and rerun tests/unit/test_lifetime_domains.py plus the bootstrap/fixed-point checks affected by generated compiler changes. Update this PR with the refreshed head SHA and local results before merge. Do not use hosted CI as a substitute.

Copy link
Copy Markdown
Contributor Author

Maintenance review after #825 merged: this branch is now one commit behind current main, and GitHub currently reports it non-mergeable. Do not force-merge it. Rebase/merge current main locally, rerun tests/unit/test_lifetime_domains.py, and confirm the former-gap arena escape case still flips while malloc behavior remains unchanged. Then update the PR with the exact locally qualified head SHA.

@godofecht
godofecht force-pushed the feat/690-arena-domain-tracking branch 2 times, most recently from 295ad02 to 543b937 Compare September 5, 2026 19:18
godofecht and others added 2 commits September 5, 2026 20:40
Harvested from completed Jules session 11936246528485187102. Binds the return
of arena_alloc(a, size) to a's borrow root so storing an arena pointer in
longer-lived storage is rejected as an LD1 domain escape. malloc is unchanged.
Flips the old negative test into positive assertions and updates
docs/language/lifetime-domains.md. tests/unit/test_lifetime_domains.py: 46 passed.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01LARAuTjD3EYMoJq2EeaKpB
Arena tracking marked every local `ptr` binding as function-local
storage. That rejected the ordinary case of stashing a heap pointer in
a global: `lib/stdlib/gif.flow:239` assigns a `malloc` result held in a
local `ptr<u8>` to `gif_block` and stopped compiling.

A local counts as function-local storage only when its initializer
actually borrows some. `_local_borrow_origin` already answers that, so
gate the set on it. A `ptr` holding a `malloc` result has no local
origin: its pointee outlives the frame.

gif.flow compiles again and the 46 lifetime-domain tests still pass.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01H7f6FndutYaViuhto1UGA8
@godofecht
godofecht force-pushed the feat/690-arena-domain-tracking branch from 543b937 to e6caad2 Compare September 5, 2026 19:40
@godofecht
godofecht merged commit 8f1d7d8 into main Sep 5, 2026
25 checks passed
@godofecht
godofecht deleted the feat/690-arena-domain-tracking branch September 5, 2026 19:57
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