bjhomer
(BJ Homer)
1
I'm working on the implementation of a change that would go into Swift 5. It appears that the following check is failing:
if (cs.getTypeChecker().getLangOpts().isSwiftVersionAtLeast(5)) {
// Do something
}
So it appears that the compiler does not believe that the Swift version is at least 5 on the swift-5.0-branch. Is that expected? Is there a better way to be checking for the Swift language version?
Alejandro
(Alejandro Alonso)
2
The compiler has not yet been bumped to Swift 5 yet. The same is on master.
Note also that you're checking the effective language version, which takes into account compatibility mode versions. Therefore, passing the option -swift-version 5 will allow the check to succeed even though the compiler version hasn't been bumped yet.
bjhomer
(BJ Homer)
5
That's true. It does mean, however, that my tests are failing because I'm writing them under the expectation of Swift 5 behavior. Is there a better way to handle this? It seems like most of the SILGen tests, at least, are just operating on the latest standard version of Swift.
Does passing -swift-version 5 to your tests not solve the problem? e.g (from generic_casts.swift):
// RUN: %target-swift-emit-silgen -swift-version 5 -module-name generic_casts -Xllvm -sil-full-demangle -enable-sil-ownership %s | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-%target-runtime %s
It's worth noting that currently tests by default use -swift-version 4, so even if the compiler version were bumped, you would still need to pass -swift-version 5 to test a Swift 5 mode specific change.
1 Like
bjhomer
(BJ Homer)
7
Ah, I see. I hadn't seen how to update the swift-version on a test-by-test basis. Thanks for pointing me in the right direction.
1 Like
No worries, sorry I should have provided an example (just edited to provide one that'll hopefully be of use to someone else).
1 Like