Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,9 @@ Currently, the `@compat` macro supports the following syntaxes:

* `repmat` is now `repeat` ([#26039])

* `range` supports `range(start, stop; length, step)` (`stop` as positional argument)
for Julia 0.7 and 1.0. ([#28708])

## New macros

* `@vectorize_1arg` and `@vectorize_2arg` are deprecated on Julia 0.6 in favor
Expand Down
5 changes: 5 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1839,6 +1839,11 @@ if VERSION < v"0.7.0-beta2.143"
end
end

if v"0.7" ≤ VERSION
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, this should be guarded with && isempty(methods(range, Tuple{Any,Any})), while the tests should not. However, on 0.7, that does not work, because of the deprecated, old range(a, len) methods. That also makes me wonder whether we actually should be adding this method on 0.7. I'd say yes, but might be worth discussing.

# https://github.com/JuliaLang/julia/pull/28708
Base.range(start, stop; kwargs...) = range(start; stop=stop, kwargs...)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, thanks to #511, this definition actually works on 0.6, too. But there we have the keyword-argument-less, two-argument methods, too. However, if we omit the Base qualification, then this will add a method to the existing Compat.range on 0.6 and to Base.range on 0.7 and later. Doesn't sound too bad.

end

include("deprecated.jl")

end # module Compat
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1518,4 +1518,10 @@ 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]

# [1.0, 1.1)
if v"0.7" ≤ VERSION && isempty(methods(range, Tuple{Any,Any}))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still has the bogus && isempty(methods(range, Tuple{Any,Any})).

Copy link
Contributor Author

@Nosferican Nosferican Oct 4, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What replacement do you recommend given that the PR hasn't been merged (can't use a precise v"1.0-xxxx")?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None. We want the tests to be run on all versions (0.7 and up, actually). If you look at the other tests, they don't come with an upper version bound. If Julia is recent enough that Compat doesn't have to do anything, we still test things work as expected/promised.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that would be

if v"0.7" ≤ VERSION

then?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. (That's what I tried to say in #633 (comment)).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition should be completely removed now (assuming we succeed in making this work for 0.6).

@test range(0, 5, length = 6) == 0.0:1.0:5.0
@test range(0, 10, step = 2) == 0:2:10
end

nothing