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-5944] array literal comparison is broken when importing foundation #48503

Open
swift-ci opened this issue Sep 20, 2017 · 4 comments
Open
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

@swift-ci
Copy link
Collaborator

Previous ID SR-5944
Radar rdar://problem/34597774
Original Reporter chriseidhof (JIRA User)
Type Bug
Environment

This is in Swift 4. It used to work in Swift 3.

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

md5: adcb77cf75eaa274c6296d87db002f39

Issue Description:

The following Swift program doesn't compile:

import Foundation
 
[1] == [1]
 

Here's the error. It only happens when you import Foundation, otherwise it's fine.

error: ambiguous use of operator '=='
[1] == [1]
    ^
 
Foundation.IndexPath:46:24: note: found this candidate
    public static func ==(lhs: IndexPath, rhs: IndexPath) -> Bool
                       ^
 
Foundation.IndexSet:2:24: note: found this candidate
    public static func ==(lhs: IndexSet, rhs: IndexSet) -> Bool
                       ^
@belkadan
Copy link
Contributor

This fails for me in the same way in Swift 3.1. It would be nice if this picked Array<Int> over the other possibilities, but I'm not sure what rule would let us do that. @rudkx, @xedin?

@xedin
Copy link
Member

xedin commented Sep 20, 2017

This is happening because of the performance hacks we have in place but actively trying to remove - solver can't get to Array<Element> overload of the `==` because there were multiple solutions found with concrete types in argument positions...

@airspeedswift
Copy link
Member

@swift-ci create

@rudkx
Copy link
Member

rudkx commented Sep 22, 2017

This can be worked around with [1] as [Int] == [1].

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
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

5 participants