Skip to content

Conversation

@tbkka
Copy link
Contributor

@tbkka tbkka commented Jan 2, 2026

Following the [Prospective Vision] Accessors
we're now ready to formally propose borrow and mutate accessors which allow a property or subscript to return a borrowed value with full exclusivity safety checks.

}
```

We believe the above problem is unlikely to arise in practice.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Swift Collections fails to compile (Swift 6.2.3, Xcode 26.2) when the yielding CoroutineAccessors experimental feature (SE-0474) is enabled.

Error: anonymous closure argument not contained in a closure

https://github.com/apple/swift-collections/blob/1.3.0/Sources/HashTreeCollections/HashNode/_HashNode.swift#L104


Swift Collections also has borrow() and mutate() methods, but they don't take trailing closures.

https://github.com/apple/swift-collections/blob/1.3.0/Sources/ContainersPreview/Box.swift#L109

Copy link
Contributor Author

@tbkka tbkka Jan 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The final SE-0474 switched to yielding borrow and yielding mutate. The PR to implement the new terms is swiftlang/swift#86277. So the issue you describe here should be resolved by that.

We started to experiment with parser-level approaches to disambiguate such cases while working on the implementation of SE-0474 but then instead changed the keywords to avoid it. We may need to revisit those ideas for these borrowing accessors.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rjmccall rjmccall added LSG Contains topics under the domain of the Language Steering Group new proposal Adds a new proposal document labels Jan 5, 2026
@DougGregor DougGregor merged commit 52fa9b2 into swiftlang:main Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LSG Contains topics under the domain of the Language Steering Group new proposal Adds a new proposal document

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants