Commit d25c421
authored
Eliminate ambiguity with Number constructors (#525)
The constructor for `T<:Number` given a vararg number of
`AbstractZero` is ambiguous with any `Number` subtype
having a varargs constructor:
```
julia> module M
using ChainRulesCore
struct X{R} <: Number
a::R
hasvalue::Bool
function X{R}(a, hv=true) where {R}
isa(hv, Bool) || error("must be bool")
return new{R}(a, hv)
end
end
end
Main.M
julia> using Test
julia> detect_ambiguities(M)
5-element Vector{Tuple{Method, Method}}:
(Main.M.X{R}(a) where R in Main.M at REPL[1]:8, (::Type{T})(x::Base.TwicePrecision) where T<:Number in Base at twiceprecision.jl:255)
(Main.M.X{R}(a) where R in Main.M at REPL[1]:8, (::Type{T})(x::AbstractChar) where T<:Union{AbstractChar, Number} in Base at char.jl:50)
((::Type{T})(xs::ChainRulesCore.AbstractZero...) where T<:Number in ChainRulesCore at /home/tim/.julia/dev/ChainRulesCore/src/tangent_types/abstract_zero.jl:28, Main.M.X{R}(a, hv) where R in Main.M at REPL[1]:8)
(Main.M.X{R}(a) where R in Main.M at REPL[1]:8, (::Type{T})(x::T) where T<:Number in Core at boot.jl:770)
((::Type{T})(xs::ChainRulesCore.AbstractZero...) where T<:Number in ChainRulesCore at /home/tim/.julia/dev/ChainRulesCore/src/tangent_types/abstract_zero.jl:28, Main.M.X{R}(a) where R in Main.M at REPL[1]:8)
```
I couldn't see any reason that method was needed at all, so I
commented it out, with a fix in case someone should discover
a need.1 parent addf6d9 commit d25c421
2 files changed
Lines changed: 19 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
119 | 137 | | |
0 commit comments