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

@_disfavoredOverload is required to "disambiguate" in a non-throwing context #73880

Open
JessyCatterwaul opened this issue May 24, 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 24, 2024

Description

No response

Reproduction

Given these two overloads…

func map<Element, Transformed>(
  _ element: Element
) -> ((Element) -> Transformed) -> Transformed {
  { transform in transform(element) }
}

func map<Element, Transformed>(
  _ element: Element
) -> ((Element) throws -> Transformed) throws -> Transformed {
  { transform in try transform(element) }
}

…this error is produced:

map(1)() { $0 + 1 } // ❌Ambiguous use of 'map'

…unless @_disfavoredOverload is added to the overload that involves throwing.

However, @_disfavoredOverload is not required to "disambiguate" when try is involved:

try! map(1)() { try $0 + 1 }

Expected behavior

The lack of try provides the necessary disambiguation.

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 24, 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