-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Check ambiguous methods in stdlib #28665
Conversation
I'm puzzled that my change invokes test failures in very different places:
--- https://travis-ci.org/JuliaLang/julia/jobs/416266235#L2059 Those happen at the code way after the code I changed. Also, I don't see how those tests can interact with the one I added: Lines 233 to 238 in d62db6a
Lines 272 to 281 in d62db6a
I'll try to debug it but please let me know if I'm making some obvious mistakes. |
Now that #28749 is merged (thanks @andreasnoack!), there are only two ambiguous methods left (occurring in SparseArrays). julia> detect_ambiguities(Base64, CRC32c, Dates, DelimitedFiles, Distributed, FileWatching,
Future, InteractiveUtils, Libdl, LibGit2, LinearAlgebra, Logging,
Markdown, Mmap, Pkg, Printf, Profile, Random, REPL,
Serialization, SHA, SharedArrays, Sockets, SparseArrays, Statistics,
SuiteSparse, Test, Unicode, UUIDs; imported=true, recursive=true)
Skipping Distributed.cluster_manager
Skipping Random.DSFMT.win32_SystemFunction036!
2-element Array{Tuple{Method,Method},1}:
(capturescalars(f, mixedargs::Tuple{Ref{Type{T}},Vararg{Any,N} where N}) where T in SparseArrays.HigherOrderFns at /home/takafumi/repos/watch/julia/usr/share/julia/stdlib/v1.1/SparseArrays/src/higherorderfns.jl:1025, capturescalars(f, mixedargs::Tuple{Union{AbstractArray{0,N} where N, Ref},Ref{Type{T}},Vararg{Any,N} where N}) where T in SparseArrays.HigherOrderFns at /home/takafumi/repos/watch/julia/usr/share/julia/stdlib/v1.1/SparseArrays/src/higherorderfns.jl:1029)
(_copy(f, args::SparseVector...) in SparseArrays.HigherOrderFns at /home/takafumi/repos/watch/julia/usr/share/julia/stdlib/v1.1/SparseArrays/src/higherorderfns.jl:968, _copy(f, args::SparseMatrixCSC...) in SparseArrays.HigherOrderFns at /home/takafumi/repos/watch/julia/usr/share/julia/stdlib/v1.1/SparseArrays/src/higherorderfns.jl:969) I changed the bound and then rebase onto master. I may have a go at SparseArrays sometime later but I think we still need this global test to avoid further ambiguities. If it's solved in SparseArrays we just need to swap |
test/ambiguous.jl
Outdated
# https://github.com/JuliaLang/julia/issues/27408 | ||
@test length(detect_ambiguities(modules...; imported=true, recursive=true)) ≤ 2 | ||
|
||
@test_broken detect_ambiguities(modules...; imported=true, recursive=true) == [] |
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.
Perhaps isempty
?
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 followed the example for Base
and Core
as I thought it makes sense:
Lines 154 to 156 in f31e28a
# Test that Core and Base are free of ambiguities | |
# not using isempty so this prints more information when it fails | |
@test detect_ambiguities(Core, Base; imported=true, recursive=true, ambiguous_bottom=false) == [] |
Shall I add a comment to clarify it?
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.
No need for a comment; it's a matter of style really :). I'm a fan of using evocatively named predicate functions where they exist. Best! (Edit: Oh gosh, apologies, I completely missed the relevant comment! Kindly ignore this comment :).)
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.
LGTM per a brief review! Thanks @tkf! :)
test/ambiguous.jl
Outdated
@test length(detect_ambiguities(modules...; imported=true, recursive=true)) ≤ 2 | ||
|
||
# not using isempty so this prints more information when it fails | ||
@test_broken detect_ambiguities(modules...; imported=true, recursive=true) == [] |
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.
This comment is response to #28665 (comment)
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.
Oh gosh, apologies, I completely missed the relevant comment in the code snippet you linked above! Absolutely, good call.
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.
The relevant code for Base
and Core
is something like 20 lines above so I think it makes sense to repeat the comment. Someone replacing @test_broken
with @test
might just swap it with isempty
if there is no comment.
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.
Agreed! :)
c5d5be3
to
5ed6ca9
Compare
Now that #30120 is merged, there is no method ambiguities in stdlib. Isn't it the best timing to merge this? |
test/ambiguous.jl
Outdated
@eval import $lib | ||
end | ||
|
||
modules = @eval [$(Base._stdlibs...)] |
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 think we should call the Base loaded_modules function here, instead of a list of symbols.
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.
Thanks. Good point. It makes the patch simpler.
bump |
Whoops, yes we should have. It needs to be rebased though now, so we can check if it is still working. |
There is no conflicts so I guess re-running CI is sufficient? |
It needs to be rebased to get a new merge commit |
Squashed & rebased. |
closes #27408
@Sacha0 I added the tests I suggested in #27408.
The nice thing I noticed is that the number of ambiguous methods is now dropped to 13 (from 25)!