Aqua.jl finds many ambiguities in Core, Base

I’m using Aqua.jl on my package and have addressed all issues that Aqua complained about except that it finds many ambiguities when I call Aqua.test_all on my package, but none if I call Aqua.test_ambiguities on my package (the latter excludes Core and Base).

There are many messages like the one below. Can I ignore such ambiguities? If not, how can I address them?

55 ambiguities found
Ambiguity #1
ForwardDiff.Dual(args...) @ ForwardDiff ~/.julia/packages/ForwardDiff/PcZ48/src/dual.jl:73
(::Type{T})(x::Base.TwicePrecision) where T<:Number @ Base twiceprecision.jl:266

Possible fix, define
  ForwardDiff.Dual(::Base.TwicePrecision)

I haven’t tried recently, but I generally avoid running Aqua’s ambiguity test. Instead I just use Test.detect_ambiguities(MyPackage) and see if the resulting list is empty.

Any idea if the checks differ between Test and Aqua?

I think Aqua passes a long list of modules, some of which are “not yours.” I think this has some history: Test.detect_ambiguities originally (many Julia releases ago) didn’t do a good job with cross-package ambiguities, and so Aqua’s fix (at the cost of false positives) was to supply a superset of modules. But then I think what happened is that Test.detect_ambiguities got fixed, and now the Aqua approach is actively counterproductive. But I am not sure of any of this, as I wasn’t involved in the work. (CC @vtjnash.)

Aqua just calls detect_ambiguities so it’s presumably down to what gets passed in and how the results are processed.

FTR, there doesn’t seem to be any ambiguities in Julia itself, at least on nightly:

julia> using Test, LinearAlgebra

julia> detect_ambiguities(Main, Base, LinearAlgebra, recursive = true)
Skipping Base.HashArrayMappedTries.delete
Skipping Base.HashArrayMappedTries.insert
Tuple{Method, Method}[]

So these are bugs in user packages, ForwardDiff, in your example:

julia> using ForwardDiff

julia> detect_ambiguities(Main, Base, LinearAlgebra, ForwardDiff, recursive = true)
Skipping Base.HashArrayMappedTries.delete
Skipping Base.HashArrayMappedTries.insert
26-element Vector{Tuple{Method, Method}}:
[...]

Right, albeit that OTOH Aqua claims that by default it tests for ambiguities in the package itself, Core, and Base.