You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#if swift(...) is testing the language version and not the compiler version. We (almost) always want to check the compiler version.
(This ticket should be for all repos in the swift-nio* family)
Consider this program
#if swift(>=5.0)
print("I'm Swift language version 5+")
#endif
#if compiler(>=5.0)
print("I'm Swift compiler version 5+")
#endif
#if swift(>=6.0)
print("I'm Swift language version 6+")
#endif
#if compiler(>=6.0)
print("I'm Swift compiler version 6+")
#endif
output (on a recent Swift 6 preview snapshot)
language version 5 (default):
$ swiftc t6.swift && ./t6
I'm Swift language version 5+
I'm Swift compiler version 5+
I'm Swift compiler version 6+
language version 4:
$ swiftc -swift-version 4 t6.swift && ./t6
I'm Swift compiler version 5+
I'm Swift compiler version 6+
language version 6:
$ swiftc -swift-version 6 t6.swift && ./t6
I'm Swift language version 5+
I'm Swift compiler version 5+
I'm Swift language version 6+
I'm Swift compiler version 6+
Please note how compiler does the right thing but swift does not?
The text was updated successfully, but these errors were encountered:
But back then it was a little more difficult because #if compiler didn't exist in Swift 4.{0,1,2}. So we had to use the weird 4.0.150 versions to mean "Swift 4.1 compiler in Swift 4 language mode"
#if swift(...)
is testing the language version and not the compiler version. We (almost) always want to check the compiler version.(This ticket should be for all repos in the
swift-nio*
family)Consider this program
output (on a recent Swift 6 preview snapshot)
language version 5 (default):
language version 4:
language version 6:
Please note how
compiler
does the right thing butswift
does not?The text was updated successfully, but these errors were encountered: