-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Parser] Support "<" unary operator in #if swift() and #if compiler() expressions #17960
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
[Parser] Support "<" unary operator in #if swift() and #if compiler() expressions #17960
Conversation
Why not just lift the restriction on comparison operators altogether? |
We don't want to support |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actual implementation looks pretty good, just a few nitpicks. Merging needs to wait for the review, of course, or for the Core Team to formally say this doesn't need one (still possible given Chris's positive feedback on the forum thread).
912a2e1
to
5823273
Compare
Until now, only ">=" was supported in #if swift() expressions, for example: ```#if swift(>=2.1) ```#endif This means that if we want to evaluate code only when the language version is less than a particular version we need to do the following: ```#if !swift(>=2.1) ```#endif An alernative to make this more readable (the "!" can be easily missed in a code review) is to introduce another supported unary operator, "<". The previous example could be rewritten like this: ```#if swift(<2.1) ```#endif This commit adds support for that unary operator, along with some tests.
5823273
to
e66095b
Compare
SE-0224 has been approved, so this is clear to land once this PR is approved. |
@tkremenek, I think this is waiting on you. @swift-ci Please test |
Re-running CI against latest master. @swift-ci test |
Swift-evolution proposal: swiftlang/swift-evolution#877
Resolves #49401.
Until now, only ">=" was supported in #if swift() expressions, for example:
This means that if we want to evaluate code only when the language version is
less than a particular version we need to do the following:
An alternative to make this more readable (the "!" can be easily missed in a code
review) is to introduce another supported unary operator, "<". The previous
example could be rewritten like this:
This commit adds support for that unary operator, along with some tests.