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-7476] Incorrect “ambiguous operator” error #50019

Closed
NevinBR opened this issue Apr 19, 2018 · 2 comments
Closed

[SR-7476] Incorrect “ambiguous operator” error #50019

NevinBR opened this issue Apr 19, 2018 · 2 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

@NevinBR
Copy link
Contributor

NevinBR commented Apr 19, 2018

Previous ID SR-7476
Radar None
Original Reporter @NevinBR
Type Bug
Status Resolved
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, TypeChecker
Assignee None
Priority Medium

md5: 63373d06282f6e25f06e5a5947d9a447

duplicates:

  • SR-5181 Protocol extension with constrained associated type doesn't work when using custom operator

Issue Description:

When a type implements an operator, and conditionally conforms to a protocol which requires that operator, the compiler produces an “ambiguous use of operator” error when it is used:

protocol A {
    static func +(lhs: Self, rhs: Self)
}

protocol B: A {}

struct Foo<T: A> {
    static func + (lhs: Foo, rhs: Foo) {}
}

extension Foo: A where T: B {}

extension Foo where T: B {
    func foo() { self + self }    // error: ambiguous use of operator '+'
}

If the requirement is a function rather than an operator, the code will compile.

This bug was discussed on the Swift forums here.

@belkadan
Copy link
Contributor

cc @rudkx, @xedin

@xedin
Copy link
Member

xedin commented Apr 21, 2018

Thanks for the report, @NevinBR! I think this is duplicate of SR-5181, and I'm currently working on the patch (#15946 which is going to rank protocol declarations vs. extensions and concrete types correctly.

@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

3 participants