Skip to content
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

Expected assignment to opaque type fails #73789

Open
Alc-Alc opened this issue May 21, 2024 · 0 comments
Open

Expected assignment to opaque type fails #73789

Alc-Alc opened this issue May 21, 2024 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. type checker Area → compiler: Semantic analysis

Comments

@Alc-Alc
Copy link

Alc-Alc commented May 21, 2024

Description

The line let notWorking: () -> some View = { EmptyView() } in the example fails with the following error.

error: cannot convert value of type 'EmptyView' to closure result type 'some View'

Reproduction

protocol View { }

struct EmptyView: View { }

let working: some View = EmptyView()

func throwAway(closure: () -> some View) -> some View {
    closure()
}

print(throwAway { EmptyView() })

let notWorking: () -> some View = { EmptyView() }

Expected behavior

No errors

Environment

swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0

Additional information

I initially asked this in https://forums.swift.org/t/need-help-understanding-opaque-types/71988 and I was suggested to file a bug here.

@Alc-Alc Alc-Alc added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels May 21, 2024
@hborla hborla added type checker Area → compiler: Semantic analysis and removed triage needed This issue needs more specific labels labels Jul 14, 2024
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. type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants