Skip to content

Amend SE-0224 to include #if compiler as well. #897

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

Merged
merged 1 commit into from
Sep 4, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions proposals/0224-ifswift-lessthan-operator.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ code:
#if !swift(>=4.2)
// This will only be executed if the Swift version is less than 4.2.
#endif

#if !compiler(>=4.2)
// This will only be executed if the Swift compiler version is less than 4.2.
#endif
```

With the introduction of support for the "<" unary operator, the
Expand All @@ -39,6 +43,10 @@ refactored code would be more clear and readable:
#if swift(<4.2)
// This will only be executed if the Swift version is less than 4.2.
#endif

#if compiler(<4.2)
// This will only be executed if the Swift compiler version is less than 4.2.
#endif
```

In the former snippet, the `!` can be easily missed in a code
Expand All @@ -53,8 +61,8 @@ example.
## Proposed solution

The solution is small change in the parser so that the operator "<" is
supported. Diagnostic messages about invalid unary operators must be
updated as well.
supported for both the `#if swift` and `#if compiler` conditions. Diagnostic
messages about invalid unary operators must be updated as well.

## Detailed design

Expand Down