Repository navigation
Sema: reads of a place are refused while a closure mutating it is alive (§12.4, #1691) - #1694
Merged
Merged
Conversation
…ew of it — reads are refused while it is alive (§12.4, D62, #1691) `let g = () => n += 1; g(); let seen = n; g()` was accepted: the binding's borrow of `n` was registered SHARED whatever the closure's body did, so only mutations of `n` were refused. The binding's entry now takes its kind from the closure's capture summary (EXCLUSIVE when the body writes the place), the mutation check consults named exclusive entries, and a new read check refuses a read of the place while the closure is alive — a view whose last use is behind the read is dead and removed, exactly as for mutations. `move ||` snapshots are untouched. WITH_DEBUG_BORROWS=1 dumps the borrow table at binding registration and at every read check.
Contributor
Author
|
Battery verdict — green. Pinned seed |
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 #1691. A
let-bound non-moveclosure whose body writes a captured place now registers an exclusive view of it (from its capture summary); reading the place before the closure's last use is refused with a diagnostic naming both, mutations keep their existing refusal, and a dead view (last use behind the read) is removed as before. Fixtures: two compile-error, one behavior (read after last use;move ||snapshot). Probes: the four D62 shapes give the expected verdicts; all closure fixtures in both lanes unchanged. Draft until the pinned-seed battery is green.