A common, borderline universal experience when starting with Swift concurrency is to begin with Swift 5 mode and with strict-concurrency
set to minimal
. This allows developers to use quite a lot of concurrency features without getting any feedback from the compiler. By the time you do get around to complete
or Swift 6 mode, you might have built quite a lot of problematic systems. But way worse is that, this allows a developer to form incorrect mental models of how Swift concurrency works. I have regularly encountered this phenomenon.
I'd like to get feedback on the idea of adding a fourth mode to strict-concurrency
. This mode would behave like complete
, but would only present diagnostics within async function bodies. I've come up with the name usage
, but I'm definitely open to suggestions here.
I think that a mode like usage
would introduce more progressive disclosure to the concurrency system. Developers are accustomed to the compiler providing feedback to them as they learn new language features. They expect it to work that way. Of course complete
does that, but it also brings along a lot of other, unrelated diagnostics. And that makes it much harder to use when experimenting in even a modest-sized code base.
I don't have a great idea on how this new mode could be introduced into the system such that it could be a default, though. Wholesale changing the default would have wide-spread impact. But, I still think there's value in at least considering this as an option. I could definitely see this mode could be a useful tool for incremental migration towards Swift 6. It would provide a way for a module author to enforce correctness in new, asynchronous code, without being burdened by un-migrated areas.
Anyways I'd love to hear your thoughts on this idea! I'm especially interested in hearing about how difficult such a change would be to implement technically, as I have zero experience with the compiler's diagnostic systems.
Update: Could it be that this is what targeted
is supposed to do? I tried out a few tests with this mode, which I admit I'm not very familiar with, and found it easy to introduce races using the Task
APIs. But I wonder if that's just a bug?