Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
6 changes: 6 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1839,6 +1839,12 @@ if VERSION < v"0.7.0-beta2.143"
end
end

if v"0.7" ≤ VERSION && isempty(methods(range, Tuple{Any,Any}))
# https://github.com/JuliaLang/julia/pull/28708
Base.range(start, stop; length::Union{Integer,Nothing}=nothing, step=nothing) =
Base._range(start, step, stop, length)
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should be calling this internal function. Why not use the old range method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I took it from the un merged PR, but good point.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Calling the lowering function does make the code simpler than the various cases using the current range method.

Copy link
Member

Choose a reason for hiding this comment

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

Doesn't just Base.range(start, stop; kwargs...) = range(start; stop=stop, kwargs...) work?

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