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

[SR-8411] Inconsistent ambiguity with optional and non-optional inout-to-pointer #50936

Closed
hamishknight opened this issue Jul 30, 2018 · 3 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis

Comments

@hamishknight
Copy link
Collaborator

Previous ID SR-8411
Radar None
Original Reporter @hamishknight
Type Bug
Status Closed
Resolution Done
Environment

Swift version 4.2-dev (LLVM a4d539e482, Clang 773ac0251a, Swift 74466883b6)
Target: x86_64-apple-darwin17.6.0

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, TypeChecker
Assignee None
Priority Medium

md5: 500e52ccedfcf9fc8297bb18da8ec065

Issue Description:

The following code only generates ambiguity errors in 2 out of the 3 cases:

struct S {
  init(_ x: UnsafeMutablePointer<Int>) {}
  init(_ x: UnsafeMutablePointer<Int>?) {}

  static func foo(_ x: UnsafeMutablePointer<Int>) {}
  static func foo(_ x: UnsafeMutablePointer<Int>?) {}
}

var foo = 0
_ = S(&foo) // unambiguous
_ = S.init(&foo) // ambiguous
_ = S.foo(&foo) // also ambiguous

I think we should treat all 3 cases consistently.

@hamishknight
Copy link
Collaborator Author

Briefly looking into it, it appears to be due to a difference in whether we mark the type variable for the argument tuple as TVO_PrefersSubtypeBinding.

@belkadan
Copy link
Contributor

Certainly seems like all three of these should prefer the non-optional overload, yeah. cc @rudkx, although some of this code is my fault.

@hamishknight
Copy link
Collaborator Author

Fixed by #28141

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
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. compiler The Swift compiler in itself type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

2 participants