-
Notifications
You must be signed in to change notification settings - Fork 22
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
Enable Aqua.jl
's ambiguity check
#936
Conversation
There seems to be more behind this as initially expectes. I continue later. |
src/gap_to_julia.jl
Outdated
@@ -133,15 +133,15 @@ gap_to_julia(::Type{T}, x::GapInt) where {T<:Integer} = T(x) | |||
gap_to_julia(::Type{Rational{T}}, x::GapInt) where {T<:Integer} = Rational{T}(x) | |||
|
|||
## Floats | |||
gap_to_julia(::Type{T}, obj::GapObj) where {T<:AbstractFloat} = T(obj) | |||
gap_to_julia(::Type{T}, obj::GapObj) where {T<:AbstractFloat} = applicable(T, obj) ? T(obj) : T(Float64(obj)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am really uncomfortable with using applicable
here, IMHO this results in difficult to understand and handle code.
I think a more appropriate fix is to just do
gap_to_julia(::Type{T}, obj::GapObj) where {T<:AbstractFloat} = applicable(T, obj) ? T(obj) : T(Float64(obj)) | |
gap_to_julia(::Type{Float64}, obj::GapObj) = Float64(obj) |
and anyone who wants to convert to stuff to Float32
or BigFloat
has to deal with it by themselves (e.g. for a GAP big int it's a bad idea to first convert to Float64 in that case).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After looking again through the Float stuff, it seems that it caused no ambiguities, and it is fundamentally different to the removed String stuff, as it does not use a magic convert
. So this doesn't need to be changed at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, great! (Sorry, didn't see this comment before)
2f6ddfd
to
6e57e62
Compare
Codecov Report
@@ Coverage Diff @@
## master #936 +/- ##
==========================================
- Coverage 75.64% 75.62% -0.02%
==========================================
Files 51 51
Lines 4171 4169 -2
==========================================
- Hits 3155 3153 -2
Misses 1016 1016
|
Parts of this have already been merged as #937.
(::Type{<:AbstractString})(::GapObj)
. This led to ambiguities withTest.GenericString
,LazyString
,Core.Compiler.LazyString
. The only real removals here are forSubString
andSubstitutionString
as the other subtypes ofAbstractString
either have their specialized function or didn't work anyway due to ambiguities.It furthermore removes the unclear
gap_to_julia(AbstractString, ...)
(as it didn't specify what exactly to return). The implementation chose to return a simpleString
. I made that a bit more clear. Even the documentation says that one should putString
as the first argument (cf.GAP.jl/src/gap_to_julia.jl
Line 78 in 01b5c13
Due to the AbstractString stuff above, I would technically consider this breaking. (E.g.
SubString(GAP.evalstr("\"foo\""))
used to work, but now needs to beSubString(String(GAP.evalstr("\"foo\"")))
.)Once this is merged,
GAP.jl
fulfills all ofAqua.jl
's tests! 🎉