Skip to content

Any vs. any Sendable discrepancies are marked as errors for uses of inout properties #79361

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

Closed
jmschonfeld opened this issue Feb 13, 2025 · 0 comments · Fixed by #79382
Closed
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. Concurrencу Area → standard library: The `Concurrency` module under the standard library umbrella concurrency Feature: umbrella label for concurrency language features expressions Feature: expressions @preconcurrency Feature → attributes: The @preconcurrency attribute Sendable Area → standard library: The Sendable protocol

Comments

@jmschonfeld
Copy link
Contributor

Description

When calling a function with an inout property, if the type of the value provided mismatches due to Sendable conformances (even if the provided variable is @preconcurrency the mismatch is diagnosed as an error even in Swift 5 mode.

Reproduction

@preconcurrency var d = Dictionary<String, any Sendable>()
func foo(_: inout Dictionary<String, Any>) {}
foo(&d) // Inout argument could be set to a value with a type other than '[String : any Sendable]'; use a value declared as type 'Dictionary<String, Any>' instead

Expected behavior

I'd expect this to be a warning in Swift 5 mode for clients not opting into strict concurrency checking

Environment

Tested with a reason Swift 6.1 development snapshot

Additional information

No response

@jmschonfeld jmschonfeld added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels concurrency Feature: umbrella label for concurrency language features Concurrencу Area → standard library: The `Concurrency` module under the standard library umbrella Sendable Area → standard library: The Sendable protocol @preconcurrency Feature → attributes: The @preconcurrency attribute and removed triage needed This issue needs more specific labels labels Feb 13, 2025
@xedin xedin added the expressions Feature: expressions label Feb 13, 2025
@xedin xedin closed this as completed in 484e0a7 Feb 15, 2025
xedin added a commit to xedin/swift that referenced this issue Feb 17, 2025
…positions

It should be possible to pass values with `any Sendable` as arguments
to `inout` parameters that expect `Any`. This is pretty much the same
as an l-value conversion.

Resolves: swiftlang#79361
Resolves: rdar://144794132
(cherry picked from commit 484e0a7)
xedin added a commit to xedin/swift that referenced this issue Feb 17, 2025
…positions

It should be possible to pass values with `any Sendable` as arguments
to `inout` parameters that expect `Any`. This is pretty much the same
as an l-value conversion.

Resolves: swiftlang#79361
Resolves: rdar://144794132
(cherry picked from commit 484e0a7)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. Concurrencу Area → standard library: The `Concurrency` module under the standard library umbrella concurrency Feature: umbrella label for concurrency language features expressions Feature: expressions @preconcurrency Feature → attributes: The @preconcurrency attribute Sendable Area → standard library: The Sendable protocol
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants