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-3318] Operator matching bug #45906

Open
an0 mannequin opened this issue Dec 2, 2016 · 1 comment
Open

[SR-3318] Operator matching bug #45906

an0 mannequin opened this issue Dec 2, 2016 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself regression swift 3.0 type checker Area → compiler: Semantic analysis

Comments

@an0
Copy link
Mannequin

an0 mannequin commented Dec 2, 2016

Previous ID SR-3318
Radar None
Original Reporter @an0
Type Bug
Environment

Swift 3.0.1

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

md5: 198b215af0ca093eeba57a059779685a

Issue Description:

public prefix func - (v: CGVector) -> CGVector {
    return CGVector(dx: -v.dx, dy: -v.dy)
}

public func + (p: CGPoint, v: CGVector) -> CGPoint {
    return CGPoint(x: p.x + v.dx, y: p.y + v.dy)
}

public func - (p: CGPoint, v: CGVector) -> CGPoint {
    return p + (-v)
}

public func - (lhs: CGPoint, rhs: CGPoint) -> CGVector {
    return CGVector(dx: rhs.x - lhs.x, dy: rhs.y - lhs.y)
}


let points = [CGPoint.zero, CGPoint.zero, CGPoint.zero]
let startPoint = points[0] - (points[1] - points[0]) // ambiguous reference to member '-'

Compiler reports this error:

error: ambiguous reference to member '-'
let startPoint = points[0] - (points[1] - points[0])
                                        ^

note: found this candidate
public func - (p: CGPoint, v: CGVector) -> CGPoint {
            ^

note: found this candidate
public func - (lhs: CGPoint, rhs: CGPoint) -> CGVector {
            ^

I don't see how this is ambiguous.

@an0
Copy link
Mannequin Author

an0 mannequin commented Dec 2, 2016

It is a regression because the same code compiles in Swift 2.3.

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

No branches or pull requests

1 participant