Skip to content

Conversation

allevato
Copy link
Member

Since this is another "stackable keyword-modified expression" situation, I've given the same kind of handling as try and await, where we have a group that tries to encompass the entire sequence of keywords and the following token (if it is an identifier in a callable non-compound expression) to avoid breaking unnecessarily in those situations.

The only subtle difference is that unsafe is a contextual keyword, so it must not be separated from the following identifier/keyword by a line break. We use a fixed space to keep it glued to the following token in all circumstances.

I've shuffled the pretty-printer tests for try/await around a bit so that we have a single file to handle the behavior for all of these keyword-modified expressions. I think it's cleaner.

Fixes #972.

Copy link
Contributor

@bnbarham bnbarham left a comment

Choose a reason for hiding this comment

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

Nice!

@allevato allevato merged commit 40962a5 into swiftlang:main Apr 2, 2025
18 checks passed
@allevato allevato deleted the unsafe branch April 2, 2025 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants