Default swift language version for a given toolchain version

I just ran into this versioning issue, got some questions about this. I was aware that this decision was announced earlier this year, but was surprised by the concrete implications recently:

> cat check.swift
#if swift(>=6.0)
print("got to 6.0")
#else
print("no go to 6.0")
#endif
> ./swift-DEVELOPMENT-SNAPSHOT-2024-07-29-a-ubi9/usr/bin/swiftc check.swift  && ./check
no go to 6.0
> ./swift-6.0-DEVELOPMENT-SNAPSHOT-2024-08-02-a-ubi9/usr/bin/swiftc check.swift  && ./check
no go to 6.0

> ./swift-DEVELOPMENT-SNAPSHOT-2024-07-29-a-ubi9/usr/bin/swiftc check.swift -swift-version 6 && ./check
got to 6.0

I understand that most Swift code out there now expects language mode 5 and language mode 6 introduces breaking changes, but it is quite weird that the upcoming 6.0 and trunk 6.1 compilers now default to -swift-version 5 internally.

Has the converse default been considered, ie the 6.0 compiler defaults to language mode 6 internally but Xcode and SwiftPM pass in -swift-version 5 to the compiler by default and override it? That would only leave external build systems like CMake or Bazel to decide if they also want to pass in -swift-version 5 by default for the Swift 6 toolchain.

If that's not going to work, what is the timeline with keeping language mode 5 the default for future compilers: indefinitely or is it the hope to switch the compiler default to language mode 6 sometime in the next year or two?

I already see projects switching to wrongly use #if compiler(>=6) to gate Swift 6 language features and work around this problem.

3 Likes