Skip to content

[region-isolation] Improve the error we emit for closure literals captured as a sending parameter. #75873

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

gottesmm
Copy link
Contributor

@gottesmm gottesmm commented Aug 13, 2024

[region-isolation] Improve the error we emit for closure literals captured as a sending parameter.

Specifically:

  1. I changed the main error message to focus on the closure and that the closure
    is being accessed concurrently.

  2. If we find that we captured a value that is the actual isolation source, we
    emit that the capture is actually actor isolated.

  3. If the captured value is in the same region as the isolated value but is not
    isolated, we instead say that the value is accessible from *-isolated code or
    code within the current task.

  4. If we find multiple captures and we do not which is the actual value that was
    in the same region before we formed the partial apply, we just emit a note on
    the captures saying that the closure captures the value.

  5. I changed the diagnostics from using the phrase "task-isolated" to use some
    variant of accessible to code in the current task.

The idea is that in all situations we provide a breadcrumb that the user can
start investigating rather than just saying that the closure is "task-isolated".

rdar://133798044

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

@gottesmm gottesmm force-pushed the pr-6c64f2f0a43f93b59babd44b8bac2c396a039e2f branch from f029fb4 to c6d3554 Compare August 13, 2024 23:45
@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

…tured as a sending parameter.

Specifically:

I changed the main error message to focus on the closure and that the closure
is being accessed concurrently.

If we find that we captured a value that is the actual isolation source, we
emit that the capture is actually actor isolated.

If the captured value is in the same region as the isolated value but is not
isolated, we instead say that the value is accessible from *-isolated code or
code within the current task.

If we find multiple captures and we do not which is the actual value that was
in the same region before we formed the partial apply, we just emit a note on
the captures saying that the closure captures the value.

I changed the diagnostics from using the phrase "task-isolated" to use some
variant of accessible to code in the current task.

The idea is that in all situations we provide a breadcrumb that the user can
start investigating rather than just saying that the closure is "task-isolated".

From a preconcurrency perspective, I made it so that we apply the preconcurrency
behavior of all of the captures. This means that if one of the captures is
preconcurrency, we apply the preconcurrency restriction to the closure. This is
one step towards making it so that preconcurrency applies at the region level...
we just are not completely there yet.

rdar://133798044
@gottesmm gottesmm force-pushed the pr-6c64f2f0a43f93b59babd44b8bac2c396a039e2f branch from c6d3554 to 4bb2e4f Compare August 14, 2024 17:41
@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

@gottesmm
Copy link
Contributor Author

Linux failed in Foundation. Its unrelated.

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test linux platform

1 similar comment
@gottesmm
Copy link
Contributor Author

@swift-ci smoke test linux platform

@gottesmm gottesmm enabled auto-merge August 15, 2024 20:35
@gottesmm gottesmm merged commit 0371349 into swiftlang:main Aug 16, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant