Skip to content

ambiguity error with non-applicable methods #31993

Closed
@rfourquet

Description

@rfourquet
julia> g(::Type{<:AbstractVector{T}}, ::Int) where {T} = 1

julia> g(Vector, 1)
ERROR: MethodError: no method matching g(::Type{Array{T,1} where T}, ::Int64)
Closest candidates are:
  g(::Type{#s1} where #s1<:AbstractArray{T,1}, ::Int64) where T at REPL[1]:1
Stacktrace:
 [1] top-level scope at REPL[2]:1

julia> g(::Type{Vector}, ::Any) = 2

julia> g(Vector, 1)
ERROR: MethodError: g(::Type{Array{T,1} where T}, ::Int64) is ambiguous. Candidates:
  g(::Type{#s1} where #s1<:AbstractArray{T,1}, ::Int64) where T in Main at REPL[1]:1
  g(::Type{Array{T,1} where T}, ::Any) in Main at REPL[3]:1
Possible fix, define
  g(::Type{Array{T,1} where T}, ::Int64)
Stacktrace:
 [1] top-level scope at REPL[4]:1

julia> f() = g(Vector, 1); f() # works on Julia 1.1 ! But errors on master
2

The last line with f is the reason why tests in my package where passing on 1.1 but not on master.

Metadata

Metadata

Assignees

Labels

bugIndicates an unexpected problem or unintended behaviortypes and dispatchTypes, subtyping and method dispatch

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions