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

Bad error messaging when opening multiple existentials #59691

Open
mbrandonw opened this issue Jun 24, 2022 · 1 comment
Open

Bad error messaging when opening multiple existentials #59691

mbrandonw opened this issue Jun 24, 2022 · 1 comment
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@mbrandonw
Copy link
Contributor

mbrandonw commented Jun 24, 2022

Describe the bug

The following code is invalid because the two opened existentials may have different types, but the error message does not explain that well:

func equals(_ lhs: Any, _ rhs: Any) -> Bool? {
  func open<A: Equatable>(_ lhs: A, _ rhs: A) -> Bool {
    lhs == rhs
  }

  guard
    let lhs = lhs as? any Equatable,
    let rhs = rhs as? any Equatable
  else { return nil }


  return open(lhs, rhs)
}

🛑 Type 'any Equatable' cannot conform to 'Equatable'

Expected behavior
A better error message that lets the user know it's not possible to open multiple existentials.

Environment

  • OS: 12.4 (21F79)
  • Xcode Version/Tag/Branch: Version 14.0 beta 2 (14A5229c)
@mbrandonw mbrandonw added the bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. label Jun 24, 2022
@hborla
Copy link
Member

hborla commented Jun 28, 2022

Great idea for a tailored error message, thanks!

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.
Projects
None yet
Development

No branches or pull requests

2 participants