Skip to content
This repository was archived by the owner on Jun 19, 2026. It is now read-only.

Ownership: show borrow origin for active-borrow conflicts#58

Merged
itsfuad merged 1 commit into
mainfrom
borrow-conflict-origin-label-fix
Apr 27, 2026
Merged

Ownership: show borrow origin for active-borrow conflicts#58
itsfuad merged 1 commit into
mainfrom
borrow-conflict-origin-label-fix

Conversation

@itsfuad

@itsfuad itsfuad commented Apr 27, 2026

Copy link
Copy Markdown
Member

Summary

Improve ownership diagnostics for borrow conflicts (T0037) by tracking borrow origin on owner state and emitting a secondary "borrow created here" label directly from owner metadata.

What changed

  • Moved active borrow-origin tracking to owner-side state (activeBorrowLoc) in ownership value scope state.
  • Updated bind/release/merge paths to keep owner-side borrow origin metadata accurate.
  • Simplified conflict reporting path to look up owner directly instead of reverse-scanning borrower entries.
  • Kept location normalization so labels always carry file info when available.
  • Added regression test fixture under tests/repro/borrow_conflict_active_borrow_label.fer.

Validation

  • go test ./internal/analysis/semantics/ownership -count=1
  • Manual repro with ferret run tests/repro/borrow_conflict_active_borrow_label.fer shows:
    • secondary label: borrow created here
    • primary label: cannot use value while a mutable borrow is live

Notes

No pass-through wrappers added. Changes stay scoped to ownership analysis and diagnostics behavior.

@itsfuad itsfuad force-pushed the borrow-conflict-origin-label-fix branch from 8725336 to 575b8fb Compare April 27, 2026 19:15
@itsfuad itsfuad merged commit 5d31f91 into main Apr 27, 2026
2 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant