Skip to content

[typeck]: reject return-path overlapping mut borrow (PHX-borrow-5) - #155

Merged
JamalLyons merged 1 commit into
trunkfrom
agent/v0-sprint/20260621-borrow-return-path
Jun 21, 2026
Merged

[typeck]: reject return-path overlapping mut borrow (PHX-borrow-5)#155
JamalLyons merged 1 commit into
trunkfrom
agent/v0-sprint/20260621-borrow-return-path

Conversation

@JamalLyons

Copy link
Copy Markdown
Member

Summary

  • Treat mutable borrows formed in return operands as ephemeral (same snapshot/restore model as call arguments), so overlap is checked without leaving stale active borrows after the return statement.
  • Add unit tests in source/phx-compiler/tests/typeck.rs for explicit return, trailing return, distinct-binding acceptance, and non-persisting return borrows.

Test plan

  • just fmt
  • cargo test -p phx-compiler typeck
  • just pre-commit

Made with Cursor

Treat mutable borrows formed in return operands as ephemeral (like call arguments) so overlap is checked without leaving stale active borrows after return.

Co-authored-by: Cursor <cursoragent@cursor.com>
@JamalLyons
JamalLyons merged commit f7654fb into trunk Jun 21, 2026
1 check passed
@JamalLyons
JamalLyons deleted the agent/v0-sprint/20260621-borrow-return-path branch June 21, 2026 18:34
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