Skip to content

[6.1] Ensure that distributed functions with typed throws can be called from outside the actor #79150

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

DougGregor
Copy link
Member

  • Explanation: Calls to distributed actor functions from outside the actor can throw either from the distributed function itself (if it's throwing) or from the distributed actor system (if something prevents the call from succeeding). When the distributed function used typed throws, the compiler would incorrectly determine that the call site would throw the error type of the distributed function, without accounting for the any Error thrown by the distributed actor system. This allows some code to incorrectly be accepted by the type checker, and would crash the compiler in later phases.
  • Scope: Only affects distributed actors.
  • Original PR: Ensure that distributed functions with typed throws can be called from outside the actor #79144
  • Revier: @ktoso
  • Issue: rdar://144093249
  • Risk: Very low. Only affects calls to distributed functions that use typed throws, everything else is unchanged.
  • Testing: Updated tests.

…m outside

When calling a distributed function for an actor that might not be local,
the call can throw due to the distributed actor system producing an
error. The function might, independently, also throw. When the
function uses typed throws, we incorrectly treated the call is if it
would always throw the error type specified by the function. This
leads to incorrectly accepting invalid code, and compiler crashes in
SILGen.

The change here is to always mark calls to distributed functions
outside the actor as "implicitly throwing", which makes sure that we
treat the call sites as throwing 'any Error'. The actual handling of
the typed throw (from the local function) and the untyped throw (from
the distributed actor system) occurs in thunk generation in SILGen,
and was already handled correctly.

Fixes rdar://144093249, and undoes the ban introduced by rdar://136467528
@DougGregor DougGregor requested a review from a team as a code owner February 5, 2025 05:15
@DougGregor DougGregor changed the title Ensure that distributed functions with typed throws can be called fro… [6.1] Ensure that distributed functions with typed throws can be called from outside the actor Feb 5, 2025
@DougGregor
Copy link
Member Author

@swift-ci please test

This test was failing in some configurations due to missing availability.
Address it in the same manner as other distributed tests do, by setting
a target triple with Swift 5.7.

Fixes rdar://144229403.
@DougGregor
Copy link
Member Author

@swift-ci please test

@DougGregor DougGregor merged commit 56db39a into swiftlang:release/6.1 Feb 6, 2025
5 checks passed
@DougGregor DougGregor deleted the distributed-typed-throws-6.1 branch February 6, 2025 17:32
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.

4 participants