diff --git a/README.md b/README.md index f27f035e9..7fb029159 100644 --- a/README.md +++ b/README.md @@ -201,7 +201,7 @@ Currently, the `@compat` macro supports the following syntaxes: * `Compat.IOBuffer` supporting keyword arguments ([#25873]). -* `Compat.range` supporting keyword arguments ([#25896]). +* `Compat.range` supporting positional and keyword arguments flavors ([#25896]), ([#28708]). * `Compat.trunc`, `Compat.floor`, `Compat.ceil`, `Compat.round`, take a keyword argument for `base` and `digits`, `Compat.round` also takes `sigdigits` ([#26156], [#26670]). diff --git a/src/Compat.jl b/src/Compat.jl index 1f016d37b..c1e0bdfe6 100644 --- a/src/Compat.jl +++ b/src/Compat.jl @@ -1527,6 +1527,9 @@ end return linspace(start, stop, length) end end +elseif VERSION < v"1.0.0-DEV.57" + import Base: LinRange + range(start; kwargs...) = Base.range(start; kwargs...) else import Base: range, LinRange end @@ -1839,6 +1842,10 @@ if VERSION < v"0.7.0-beta2.143" end end +if VERSION ≤ v"1.0" || isempty(methods(range, Tuple{Any,Any})) + range(start, stop; kwargs...) = range(start; stop=stop, kwargs...) +end + include("deprecated.jl") end # module Compat diff --git a/test/runtests.jl b/test/runtests.jl index 155b801eb..815b3e173 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1518,4 +1518,8 @@ end 3 4 3 4 3 4] @test repeat([1, 2], 1, 2, 3) == [x for x in 1:2, y in 1:2, z in 1:3] +# Support for positional `stop` +@test Compat.range(0, 5, length = 6) == 0.0:1.0:5.0 +@test Compat.range(0, 10, step = 2) == 0:2:10 + nothing