Repository navigation
A use inside an f-string keeps a view alive: expr_uses_symbol walks interpolations (#1249, §21.1 rule 1) - #1254
Merged
Merged
Conversation
…nterpolations (#1249, §21.1 rule 1) `let s = &v; v.push(..); print(f"{s.len()}")` compiled and read through an invalidated view. The borrow was registered and check_mutation_against_views found it, but its liveness scan (find_last_use_in_block → expr_uses_symbol) has no NK_FSTRING arm: a view used only inside an interpolation looked dead at the mutation, so the borrow was removed as stale instead of reported. Every other use shape (`let k = s.len()`, `print(s.len())`) was diagnosed — the matrix isolated the f-string. expr_uses_symbol now walks the EXPR segments of an f-string. That exposed 24 sites in the compiler of one idiom — `let name = self.pool_resolve(sym)` (a view into self) followed by `self.emit_error(f"…{name}…")`, a `mut self` call while the view is live — rewritten mechanically to `let name: str = …` (an annotated binding is an owned demand, D22 #781). Tests: err_view_of_local_used_after_mutation (Vec push), err_view_of_local_used_after_reassign (str), behav_view_of_local_dead_before_mutation (NLL: a borrow whose last use precedes the mutation is fine).
ehartford
added a commit
that referenced
this pull request
Sep 21, 2026
A 504 from GitHub releases on the Windows x86_64 lane's LLVM SDK fetch failed PR #1254 23 s in, before any With code ran. curl was invoked as `curl -fL -o` with no retry on all eight fetches; each now retries five times with a five-second delay on any transient error. Co-authored-by: Eric Hartford <[email protected]>
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.
Fixes #1249.
let s = &v; v.push(..); print(f"{s.len()}")compiled and read through an invalidated view. The borrow was registered andcheck_mutation_against_viewsfound it, but the liveness scan (find_last_use_in_block → expr_uses_symbol) had noNK_FSTRINGarm: a view used only inside an interpolation looked dead at the mutation, so the borrow was dropped as stale instead of reported. Every other use shape (let k = s.len(),print(s.len())) was already diagnosed — the matrix isolated the f-string.expr_uses_symbolnow walks an f-string's EXPR segments. That exposed 24 sites in the compiler of one idiom —let name = self.pool_resolve(sym)(a&strview intoself) followed byself.emit_error(f"…{name}…"), amut selfcall while the view is live — rewritten mechanically (a With script over the diagnostics) tolet name: str = …, an owned demand (D22 #781). A query showed no such sites outsidesrc/.Tests:
err_view_of_local_used_after_mutation(Vec push),err_view_of_local_used_after_reassign(str),behav_view_of_local_dead_before_mutation(NLL: a borrow whose last use precedes the mutation stays legal).Also filed on the way: #1253 (Sema accepts
captures[1]on a struct with no index method; prints "" in an f-string).Battery (seed-driven, worktree, ownership change alone): build, :fixpoint, :move-audit, :drop-audit, :test, :test-green, :last-green all rc=0.