Goal
Support reserved-then-activated mutable call borrows without weakening reference-origin or exclusive &mut guarantees.
Semantics
- Every mutable reference call argument reserves during left-to-right evaluation: explicit
&mut, implicit reborrow, mutable receiver, optional mutable reference, and indirect callable.
- Reads and shared borrows may overlap a reservation only when they end before activation.
- Mutation, move, free, overwrite, destruction, and nested mutable activation conflict with reserved storage.
- Activation occurs immediately before entering the callee and requires exclusive access.
Both(&mut value, Read(&value)) is valid when Read returns an owned/copied value.
Both(&mut value, &value) remains invalid because the shared reference enters the same call.
- Unequal concrete fields/fixed indexes may reserve independently; dynamic indexes and views remain conservative.
Architecture
- Keep reservation facts expression-local in existing ownership
loanContext.
- Keep persistent NLL on existing ownership CFG.
- Keep origin overlap canonical in
internal/semantics/place.
- Preserve
ReturnOriginSources and reference-return composition.
- No syntax, ABI, HIR, MIR, backend, runtime loan state, or second CFG changes.
Validation
Passed on 2026-07-19 under 2 GiB process cap:
- Focused two-phase ownership tests, 20 repeated runs.
- Full
go test -p 1 ./....
- Full
go test -race -p 1 ./....
- Full
go vet ./....
- Compiler bundle.
- Positive
x_test/runtime_borrow_conflicts runtime fixture.
- Negative
x_test/negative_borrow_conflict fixture with exactly seven intended T0037 errors and no unrelated diagnostics.
gofmt -l, git diff --check, and executable-artifact scan clean.
Follow-up to #43.
Goal
Support reserved-then-activated mutable call borrows without weakening reference-origin or exclusive
&mutguarantees.Semantics
&mut, implicit reborrow, mutable receiver, optional mutable reference, and indirect callable.Both(&mut value, Read(&value))is valid whenReadreturns an owned/copied value.Both(&mut value, &value)remains invalid because the shared reference enters the same call.Architecture
loanContext.internal/semantics/place.ReturnOriginSourcesand reference-return composition.Validation
Passed on 2026-07-19 under 2 GiB process cap:
go test -p 1 ./....go test -race -p 1 ./....go vet ./....x_test/runtime_borrow_conflictsruntime fixture.x_test/negative_borrow_conflictfixture with exactly seven intendedT0037errors and no unrelated diagnostics.gofmt -l,git diff --check, and executable-artifact scan clean.Follow-up to #43.