Skip to content

Commit 4839fd8

Browse files
committed
range: Remove one positional arg syntax
1 parent a03945e commit 4839fd8

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

base/range.jl

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ end
5050
range(start, stop; length, step)
5151
range(start; length, stop, step)
5252
range(;start, length, stop, step)
53-
range(stop)
5453
5554
Construct a specialized array with evenly spaced elements and optimized storage (an [`AbstractRange`](@ref)) from the arguments.
5655
Mathematically a range is uniquely determined by any three of `start`, `step`, `stop` and `length`.
@@ -90,9 +89,6 @@ julia> range(stop=10, step=1, length=5)
9089
julia> range(start=1, step=1, stop=10)
9190
1:1:10
9291
93-
julia> range(5)
94-
Base.OneTo(5)
95-
9692
julia> range(; length = 10)
9793
Base.OneTo(10)
9894
@@ -136,7 +132,7 @@ A `UnitRange` is not produced if `step` is provided even if specified as one.
136132
function range end
137133

138134
range(start; stop=nothing, length::Union{Integer,Nothing}=nothing, step=nothing) =
139-
_range_positional(start, step, stop, length)
135+
_range(start, step, stop, length)
140136

141137
function range(start, stop; length::Union{Integer,Nothing}=nothing, step=nothing)
142138
# For code clarity, the user must pass step or length
@@ -156,13 +152,6 @@ end
156152
range(;start=nothing, stop=nothing, length::Union{Integer, Nothing}=nothing, step=nothing) =
157153
_range(start, step, stop, length)
158154

159-
range(stop::Integer) = range_stop(stop)
160-
161-
_range_positional(stop::Any , step::Nothing, ::Nothing, len::Nothing) =
162-
_range(nothing, nothing, stop, nothing) # One arg interpreted as `stop`, could be nothing
163-
_range_positional(start::Any , step::Any , stop::Any, len::Any) =
164-
_range(start, step, stop, len)
165-
166155
_range(start::Nothing, step::Nothing, stop::Nothing, len::Nothing) = range_error(start, step, stop, len)
167156
_range(start::Nothing, step::Nothing, stop::Nothing, len::Any ) = range_length(len)
168157
_range(start::Nothing, step::Nothing, stop::Any , len::Nothing) = range_stop(stop)

test/ranges.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,14 @@
2121
r = 1:5
2222
o = Base.OneTo(5)
2323
let start=first(r), step=step(r), stop=last(r), length=length(r)
24-
@test o === range( length)
2524
@test o === range(; stop )
2625
@test o === range(; length)
2726
@test r === range(; start, stop )
2827
@test r === range(; stop, length)
2928
# the next three lines uses ==, because it changes the eltype
3029
@test r == range(; start, stop, length)
3130
@test r == range(; start, step, length)
32-
@test r == range(Float64(stop))
31+
@test r == range(; stop=Float64(stop))
3332
end
3433
end
3534
end
@@ -1458,6 +1457,7 @@ end
14581457

14591458
@testset "Bad range calls" begin
14601459
@test_throws ArgumentError range(nothing)
1460+
@test_throws ArgumentError range(5)
14611461
@test_throws ArgumentError range(1, step=4)
14621462
@test_throws ArgumentError range(; step=1, length=6)
14631463
@test_throws ArgumentError range(; step=2, stop=7.5)

0 commit comments

Comments
 (0)