Commit Graph

6 Commits

Author SHA1 Message Date
Doug Gregor
a554ad632b [Concurrency] Diagnose mutating accesses to locals from concurrent code.
Replace the existing warning about any access to a local variable from
concurrently-executing code with a more tailored error:
concurrently-executing code may read a mutable varable, but cannot
modify it. This is safe so long as we either always do by-value
captures in concurrent closures or we ensure that no mutation of that
variable can occur after the point of capture.

We'll follow up with one of those. For now... be careful out there.

Since we're promoting this to an error, narrow it down to concurrent
closures and local functions, dropping the assumption that escaping
closures "may execute concurrently."
2021-01-29 14:27:24 -08:00
Doug Gregor
8eae527ca6 Tighten up actor isolation checking for closures and local functions.
Make sure that we check the isolation of the context in which a reference
to `self` is made, rather than the context in which `self` is declared,
when checking whether we are within actor-isolated code. This ensures
that we report errors as actor-isolation errors rather than falling
back to the "may execute concurrently with" checking.
2021-01-28 21:56:07 -08:00
Doug Gregor
bffc7434fa [Concurrency] Make 'await' and 'try' implicit in async let initializer 2020-12-15 16:15:40 -08:00
Kavon Farvardin
3e613a26d8 update async-let test for implicitly async 2020-11-20 08:09:49 -08:00
Doug Gregor
33cfbbdd72 [Concurrency] Don't diagnose missing "self." in async let autoclosures. 2020-11-04 23:18:51 -08:00
Doug Gregor
58b590aa3d [Concurrency] Wrap the initializer of 'async let' in an autoclosure call.
The initializer of an 'async let' is executed as a separate child task
that will run concurrently with the main body of the function. Model
the semantics of this operation by wrapping the initializer in an
async, escaping autoclosure (representing the evaluation of the child
task), and then a call to that autoclosure (to

This is useful both for actor isolation checking, which needs to treat
the initializer as executing in concurrent code, and also (eventually)
for code generation, which needs to have that code in a closure so
that it can be passed off to the task-creation functions.

There are a number of issues with this implementation producing
extraneous diagnostics due to this closure transformation, which will
be addressed in a follow-up commit.
2020-11-04 17:32:04 -08:00