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-6634] new ambiguity in Swift 4.1 #49183

Closed
weissi opened this issue Dec 18, 2017 · 7 comments
Closed

[SR-6634] new ambiguity in Swift 4.1 #49183

weissi opened this issue Dec 18, 2017 · 7 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression swift 4.1 type checker Area → compiler: Semantic analysis

Comments

@weissi
Copy link
Member

weissi commented Dec 18, 2017

Previous ID SR-6634
Radar rdar://problem/36113283
Original Reporter @weissi
Type Bug
Status Closed
Resolution Done
Environment
$ xcrun --toolchain org.swift.3020171217a swift --version
Apple Swift version 4.1-dev (LLVM cd2d6e3b54, Clang f611516c9e, Swift 823205f609)
Target: x86_64-apple-darwin17.3.0
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, 4.1Regression, TypeChecker
Assignee @moiseev
Priority Medium

md5: 09b9e4da75815d425d138e4adb3bcba0

Issue Description:

In Swift 4.0 this compiled just fine

private func foo(_ x: UnsafeBufferPointer<UInt8>) -> Int {
    return x.lazy.filter { $0 > 127 || $0 == 0 }.count
}

in the current Swift master / Swift 4.1 snapshots it fails like this

$ xcrun --toolchain org.swift.3020171217a swiftc test.swift
test.swift:2:31: error: ambiguous use of operator '>'
    return x.lazy.filter { $0 > 127 || $0 == 0 }.count
                              ^
Swift.Comparable:158:24: note: found this candidate
    public static func > (lhs: Self, rhs: Self) -> Bool
                       ^
Swift.BinaryInteger:83:24: note: found this candidate
    public static func > <Other>(lhs: Self, rhs: Other) -> Bool where Other : BinaryInteger
                       ^
@belkadan
Copy link
Contributor

cc @rudkx, @xedin

@swift-ci create

@rudkx
Copy link
Member

rudkx commented Dec 18, 2017

@xedin, I wonder if this is related to the ranking changes you made?

Or perhaps it's due to a stdlib change?

@xedin
Copy link
Member

xedin commented Dec 18, 2017

@moiseev Looks like this is related to stdlib because I can see that solver found almost identical solutions with the only difference of `==` been inferred as BinaryInteger.==`(UInt8, Int)` and/or BinaryInteger.==`(Int, Int)` for Comparable and BigInteger solutions.

@xedin
Copy link
Member

xedin commented Jan 9, 2018

@moiseev has created PR #13817 which is going to address this.

@xedin
Copy link
Member

xedin commented Jan 9, 2018

Aforementioned PR has been merged to master. @weissi please use next nightly snapshot to verify.

@moiseev
Copy link
Mannequin

moiseev mannequin commented Mar 29, 2018

@weissi This should be fixed now. Can you please confirm and close the issue if so?

@weissi
Copy link
Member Author

weissi commented Mar 29, 2018

thanks @moiseev, confirmed working.

@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 regression swift 4.1 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

5 participants