Skip to content

Commit

Permalink
Wrap unbound_args.jl into module
Browse files Browse the repository at this point in the history
  • Loading branch information
lgoettgens committed Jul 3, 2023
1 parent 3b4dd23 commit 7376d10
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/unbound_args.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
# <https://github.com/JuliaLang/julia/pull/31972>. 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

0 comments on commit 7376d10

Please sign in to comment.