Skip to content

Ensure that distributed functions with typed throws can be called from outside the actor #79144

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
merged 1 commit into from
Feb 5, 2025

Conversation

DougGregor
Copy link
Member

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

…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
Copy link
Member Author

@swift-ci please smoke test

@ktoso ktoso added the distributed Feature → concurrency: distributed actor label Feb 5, 2025
Copy link
Contributor

@ktoso ktoso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you! Would be great to pick over to 6.1 as well.

I'd do the followup of adding the associated type in the future, but this is great until then.

@DougGregor
Copy link
Member Author

@swift-ci please test Windows

@DougGregor DougGregor enabled auto-merge February 5, 2025 05:14
@DougGregor DougGregor merged commit 246e130 into swiftlang:main Feb 5, 2025
3 checks passed
@DougGregor DougGregor deleted the distributed-typed-throws branch February 5, 2025 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
distributed Feature → concurrency: distributed actor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants