Skip to content

Commit fd9f3cb

Browse files
authored
Merge pull request #897 from apple/SE-0224-revision
Amend SE-0224 to include #if compiler as well.
2 parents dcc4394 + cd53d56 commit fd9f3cb

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

proposals/0224-ifswift-lessthan-operator.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ code:
3131
#if !swift(>=4.2)
3232
// This will only be executed if the Swift version is less than 4.2.
3333
#endif
34+
35+
#if !compiler(>=4.2)
36+
// This will only be executed if the Swift compiler version is less than 4.2.
37+
#endif
3438
```
3539

3640
With the introduction of support for the "<" unary operator, the
@@ -40,6 +44,10 @@ refactored code would be more clear and readable:
4044
#if swift(<4.2)
4145
// This will only be executed if the Swift version is less than 4.2.
4246
#endif
47+
48+
#if compiler(<4.2)
49+
// This will only be executed if the Swift compiler version is less than 4.2.
50+
#endif
4351
```
4452

4553
In the former snippet, the `!` can be easily missed in a code
@@ -54,8 +62,8 @@ example.
5462
## Proposed solution
5563

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

6068
## Detailed design
6169

0 commit comments

Comments
 (0)