You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(borrow): CORE-01 ref-to-ref binding (#177 pt3) — let r2 = r / r = s alias the borrow-graph (#395)
## Summary
Closes the documented reborrow-through-indirection gap (the first item
under "Still deferred" at the bottom of `lib/borrow.ml`). `let r2 = r`
and `r = s` — where the RHS is itself a ref-binder, not a direct
`&place`/`&mut place` — now extend the borrow-graph correctly.
- New `ref_source_borrow` helper: unifies the `&p` / `&mut p` / ref-var
lookup so `record_ref_binding` (let path) and the `StmtAssign` reborrow
block both see one extra level of indirection.
- New `is_reborrow_source` shape-only test: drives the pre-release
decision on the assign path without consulting live borrow state.
- `expire_dead_ref_bindings` now reference-counts borrows by `b_id`
across surviving aliases — a borrow is ended only when no live
ref-binder still holds it. This was the load-bearing fix: pre-change,
`let r = &x; let r2 = r` would correctly alias r2 then drop the
underlying borrow when r died, silently re-permitting writes to x.
## Refs
- #177 (CORE-01 pt3)
- One of three small slices being landed today; the other two (Slice C′
loop, Slice D captured-linears) follow in their own PRs. Slice C-full
(Polonius) is being handed off to a separate Claude.
## Test plan
- [x] `dune runtest --force` — 327 → **330 tests, 0 failures**
- [x] 3 new e2e fixtures + handlers:
- `ref_to_ref_let_aliases.affine` — positive let-path (`let r = &x; let
r2 = r; *r + *r2`)
- `ref_to_ref_protects_owner.affine` — anti-regression (write to owner
while alias is live must be rejected)
- `ref_to_ref_assign_aliases.affine` — positive assign-path (`r = s`
where s is a ref-binder)
- [x] No regression in existing borrow / Slice A / Slice B / Slice C
fixtures
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments