diff --git a/src/unbound_args.jl b/src/unbound_args.jl index 35a15601..d7e64625 100644 --- a/src/unbound_args.jl +++ b/src/unbound_args.jl @@ -33,7 +33,7 @@ h(x1::T, x2::T...) = do_something(T[x1, x2...]) ``` """ function test_unbound_args(m::Module; broken::Bool = false) - unbounds = detect_unbound_args_recursively(m) + unbounds = UnboundArgs.detect_unbound_args_recursively(m) if !isempty(unbounds) printstyled( stderr, @@ -51,19 +51,27 @@ function test_unbound_args(m::Module; broken::Bool = false) end end +module UnboundArgs + +using Test + # There used to be a bug in `Test.detect_unbound_args` when used on # a top-level module together with `recursive = true`, see # . This was fixed # some time between 1.4.2 and 1.5.4, but for older versions we # define `detect_unbound_args_recursively` with a workaround. @static if VERSION < v"1.5.4" + using Aqua: walkmodules + function detect_unbound_args_recursively(m) methods = [] walkmodules(m) do x - append!(methods, detect_unbound_args(x)) + append!(methods, Test.detect_unbound_args(x)) end return methods end else detect_unbound_args_recursively(m) = Test.detect_unbound_args(m; recursive = true) end + +end # module