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

some cannot be used instead of a generic placeholder for never-returned type inference #73558

Open
JessyCatterwaul opened this issue May 10, 2024 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels

Comments

@JessyCatterwaul
Copy link

JessyCatterwaul commented May 10, 2024

Description

some Any works for most replacements of generic placeholders that only get used one time. But it doesn't work with whatever type inference errors use.

Reproduction

Compiles:

extension Error {
  func `throw`<Never>() throws -> Never {
    throw self
  }
}

Function declares an opaque return type, but has no return statements in its body from which to infer an underlying type :

extension Error {
  func `throw`() throws -> some Any {
    throw self
  }
}

The throw function is very useful. I haven't had a use for similar, when it comes to Never returns, but the same problem occurs there:

✅:

func never<Never>() -> Never { 
  fatalError()
}

❌:

func never() -> some Any {
  fatalError()
}

Expected behavior

The versions using some Any compile.

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

No response

@JessyCatterwaul JessyCatterwaul added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels May 10, 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. triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

1 participant