Repository navigation
Fix field projections, receivers and with bindings through temporary pointers - #1633
Merged
Merged
Conversation
A field access through a pointer implicitly dereferences it. Binding-rooted places already record that dereference, but temporary-rooted places such as `pick(..).value` or `(*f()).next.value` dropped it and lowered a field projection of the pointer value itself, which normalization rejected as an invalid projection.
Receiver auto-borrows only recognized binding-rooted places, so a receiver reached through a temporary pointer, such as `(*f()).set(..)` or `f().field.set(..)`, was copied into a temporary and a `mut self` method mutated the copy. Lower receivers with the same place lowering as other places, materializing a temporary only for rvalues.
A `with` binding of a root-object provider captured only binding-rooted places. A provider reached through a temporary pointer, such as `with ((*f()).counter)` or `with (f().counter)`, was copied into a temporary, so effectful calls in the body mutated the copy. Make place lowering capture-aware and use it for `with` bindings. A captured place snapshots its pointers and dynamic indices, as captured binding places already did, so writes in the body cannot retarget it.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
cburgdorf
added a commit
that referenced
this pull request
Sep 29, 2026
The lowering and type checking for places reached through a temporary pointer landed on master (#1633, #1634). Keep this branch's extra coverage on top of it: - `temporary_pointer_field.fe` exercises reads, writes, compound assignment and explicit `mut`/`ref` borrows of fields reached through pointer-returning calls such as `orders.ptr_at(0).n`, including chained `ptr_at` calls and pointer fields of temporaries. - `borrow_custom_index_through_pointer.fe` pins that a built-in array element below a temporary pointer is borrowable, while a custom `Index` call below one is still rejected as a non-place.
sbillig
pushed a commit
that referenced
this pull request
Sep 30, 2026
The lowering and type checking for places reached through a temporary pointer landed on master (#1633, #1634). Keep this branch's extra coverage on top of it: - `temporary_pointer_field.fe` exercises reads, writes, compound assignment and explicit `mut`/`ref` borrows of fields reached through pointer-returning calls such as `orders.ptr_at(0).n`, including chained `ptr_at` calls and pointer fields of temporaries. - `borrow_custom_index_through_pointer.fe` pins that a built-in array element below a temporary pointer is borrowable, while a custom `Index` call below one is still rejected as a non-place.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A field access through a pointer implicitly dereferences it. A place rooted at a temporary pointer, such as
pick(a, b).valueor(*f()).next.value, dropped that dereference. Lowering then projected a field of the pointer value itself, which normalization rejected with an internal borrow-check error (16-0004). These now lower like(*f()).field.Two other sites copied temporary-pointer places instead of using them in place. Both silently lose writes on master:
mut selfreceivers, e.g.(*f()).set(1), borrowed a copy of the receiver.withbindings of root-object providers, e.g.with ((*f()).counter) { incr() }, bound a copy.Receivers now use the same place lowering as other places.
withbindings use a capture-aware version of it, which snapshots pointers and indices as captured binding places already did. The three fixes belong together: the projection fix alone would turnf().field.set(..)andwith (f().field)from an internal error into a lost write.