Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift 5.8 and 5.9 updates #1948

Merged
merged 4 commits into from
Jul 4, 2023
Merged

Swift 5.8 and 5.9 updates #1948

merged 4 commits into from
Jul 4, 2023

Conversation

johnfairh
Copy link
Contributor

Swift lexer updates for Swift 5.8 (and probably 5.7).
First commit:

  • Add long-term missing keywords autoreleasepool left right
  • Add recent new keywordsany distributed and #unavailable #fileID #filePath directives
  • Add 'property wrapper projection' syntax -- means non-numeric identifiers can begin with $ symbol
  • Remove incredibly old C-style __-prefixed things

Second commit is about regular expression literals which have some quirks due to being retrofitted to the language including:

  • Single-line REs can't begin/end with spaces
  • Single-line REs can have # delimiters which work like non-slash delims in other languages
  • REs don't have trailing flags
  • Multi-line REs must have # delims and always support extended syntax meaning #-end-of-line comments

There are some corners I haven't captured including turning off extended syntax inside multi-line REs.

Final commit re-alphabetizes some keyword lists without trying to think too much about why the separate lists exist.

Add new keywords and tidy up the overall list.
Support property wrapper projection syntax
@johnfairh johnfairh changed the title Swift 5.8 updates Swift 5.8 and 5.9 updates Jun 23, 2023
@johnfairh
Copy link
Contributor Author

I guess I will just keep going here for Swift 5.9:

Screenshot 2023-06-23 at 11 35 40

Simple things:

  • new declaration keywords package macro consuming borrowing
  • new keywords each consume discard
  • Nasty special ~Copyable type name - this is explicitly not a generic syntax (ie. for ~Fooable) so it seems least bad to specialise this explicitly :/

Swift 5.9 macros mean that users can define their own expression/function-type keywords that begin with ‘#’. So I’ve taken out the special cases of built-in #things as we’ve done in the past for @things. This looks good, highlights any arguments properly and improves the existing #available to match @available:
Screenshot 2023-06-23 at 11 35 11
Screenshot 2023-06-23 at 11 35 22

The special case for start-of-line is preserved to keep the 'preprocessor-like' parts different.
Screenshot 2023-06-23 at 11 34 33

@tancnle tancnle self-requested a review July 4, 2023 07:34
@tancnle tancnle added the needs-review The PR needs to be reviewed label Jul 4, 2023
@tancnle
Copy link
Collaborator

tancnle commented Jul 4, 2023

Great stuff. Thank you for the work here @johnfairh 🙇🏼 LGTM 🚀

@tancnle tancnle added this pull request to the merge queue Jul 4, 2023
Merged via the queue into rouge-ruby:master with commit 9d7ce06 Jul 4, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-review The PR needs to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants