SE-0343: Concurrency in Top-level Code

Proposal SE-0343 was accepted.

There was a minor change requested to enable the implicit main-actor protection of top-level variables without needing to call an asynchronous function from the top-level. This is done by passing -warn-concurrency to the compiler invocation.

Please note that this does not transition the top-level context to an asynchronous context, so no runloops are spun up and the overload resolution does not change.
The feature is intended to provide diagnostics, alerting you to the presence of potential data-races. Additionally, this flag transitions the top-level code context to run under main-actor protection so that reading and writing to top-level variables is synchronous.

4 Likes