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

Add Aqua tests and fix unbound type parameters #186

Merged
merged 4 commits into from
Apr 19, 2024

Conversation

devmotion
Copy link
Contributor

The PR adds Aqua tests. On master, both the tests for method ambiguities and for unbound type parameters are broken. I fixed the unbound type parameters in this PR but the method ambiguity issues are not resolved.

@kalmarek
Copy link
Owner

@devmotion thanks for those tests using Aqua! the reported overwrites seem to be real and we need to find them

@Joel-Dahne
Copy link
Collaborator

Thesis submitted, so now I have some time to take a look at this!

In total there are 28 ambiguities, they can be broken up into a few different categories:

  • Base._fast (4 ambiguities). We can add explicit cases. I also noticed some other issues with the code when looking at it.
  • (::Type{T})(x::Base.TwicePrecision) where T<:Number (6 ambiguities). We have to add an explicit case for this.
  • (::Type{T})(x::AbstractChar) where T<:Union{AbstractChar, Number} (6 ambiguities). Same as the above one.
  • (::Type{T})(x::Rational{S}) where {S, T<:AbstractFloat} (2 ambiguities). I have not been able to trigger this issue. See below.
  • (::Type{T})(z::Complex) where T<:Real (3 ambiguities). I didn't even know that this constructor existed. We can add explicit cases for it. Should we add a case for (::Type{T})(z::Acb where T<:Real also?
  • ^(::Irrational{:ℯ}, x::Number) (3 ambiguities). I had forgotten about this method, we can add explicit cases for it.
  • 4 ambiguities related to +, * and ^. It fails for AcbSeries()^ArbSeries(), but I have not been able to trigger the other cases. See below.

So there are some ambiguities that I have not been able to trigger, I'm probably missing something. They are:

Ambiguity #1
*(p::Union{Arblib.AcbPoly, Arblib.AcbSeries}, c::Number) @ Arblib ~/Syncthing/Work/Code/Arblib.jl/src/poly.jl:465
*(c::Number, p::Union{Arblib.AcbPoly, Arblib.AcbSeries, Arblib.ArbPoly, Arblib.ArbSeries}) @ Arblib ~/Syncthing/Work/Code/Arblib.jl/src/poly.jl:517

Possible fix, define
  *(::Arblib.AcbSeries, ::Union{Arblib.AcbSeries, Arblib.ArbSeries})

Ambiguity #2
+(p::Union{Arblib.AcbPoly, Arblib.AcbSeries}, c::Number) @ Arblib ~/Syncthing/Work/Code/Arblib.jl/src/poly.jl:439
+(c::Number, p::Union{Arblib.AcbPoly, Arblib.AcbSeries, Arblib.ArbPoly, Arblib.ArbSeries}) @ Arblib ~/Syncthing/Work/Code/Arblib.jl/src/poly.jl:516

Possible fix, define
  +(::Arblib.AcbSeries, ::Union{Arblib.AcbSeries, Arblib.ArbSeries})

Ambiguity #3
^(p::Arblib.ArbSeries, e::Number) @ Arblib ~/Syncthing/Work/Code/Arblib.jl/src/poly.jl:657
^(x::Number, p::Arblib.AcbSeries) @ Arblib ~/Syncthing/Work/Code/Arblib.jl/src/poly.jl:671

Possible fix, define
  ^(::Arblib.ArbSeries, ::Arblib.AcbSeries)

Ambiguity #4
Arblib.Arb(x; prec) @ Arblib ~/Syncthing/Work/Code/Arblib.jl/src/constructors.jl:17
(::Type{T})(x::Rational{S}) where {S, T<:AbstractFloat} @ Base rational.jl:133

Possible fix, define
  Arblib.Arb(::Rational{S}) where S

Ambiguity #5
Arblib.Arf(x; prec) @ Arblib ~/Syncthing/Work/Code/Arblib.jl/src/constructors.jl:11
(::Type{T})(x::Rational{S}) where {S, T<:AbstractFloat} @ Base rational.jl:133

Possible fix, define
  Arblib.Arf(::Rational{S}) where S

My attempts at triggering these are

#1
AcbSeries() * AcbSeries()
AcbSeries() * ArbSeries()

#2
AcbSeries() + AcbSeries()
AcbSeries() + ArbSeries()

#3
AcbSeries()^AcbSeries()

#4
Arb(1 // 2)
Arb(Rational{Int32}(1, 2))

#5
Arf(1 // 2)
Arf(Rational{Int32}(1, 2))

I'm preparing a PR that fixes the easy cases. Then we can see what to do with the rest.

@devmotion
Copy link
Contributor Author

It would be good to fix these but I thought it would be better to go through them in separate PRs. So I intentionally did not include any fixes in this PR.

@Joel-Dahne
Copy link
Collaborator

Yes, I guess we can merge this now then!

@Joel-Dahne Joel-Dahne merged commit 344a6a2 into kalmarek:master Apr 19, 2024
13 checks passed
@devmotion devmotion deleted the dw/aqua branch April 19, 2024 11:57
@Joel-Dahne Joel-Dahne mentioned this pull request Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants