Skip to content

Extraneous ambiguity warning: (MyType{T},T) vs (T,MyType{T}) #1631

Closed
@toivoh

Description

@toivoh

The code

abstract MyType{T}

f{T}(::MyType{T}, ::T) = 1
f{S}(::S, ::MyType{S}) = 2

produces the ambiguity warning

Warning: New definition f(S,MyType{S}) is ambiguous with f(MyType{T},T).
         Make sure f(MyType{T},MyType{S}) is defined first.

This seems like
S has been instantiated to MyType{T} in the intersection, and
T has been instantiated to MyType{S}.
But that would mean that T == MyType{MyType{T}}. No type could fulfill this, right?
(8 out of the 19 ambiguity warnings here seem to be of this kind.)

The similar case

g{T}(::MyType{T}, ::T) = 1
g{S}(::S,         ::S) = 2

does not produce an ambiguity warning, though it would have been ambiguous if there were a type T such that T == MyType{T}.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions