@@ -136,9 +136,7 @@ A `UnitRange` is not produced if `step` is provided even if specified as one.
136
136
function range end
137
137
138
138
range (start; stop= nothing , length:: Union{Integer,Nothing} = nothing , step= nothing ) =
139
- stop === length === step === nothing ?
140
- _range (nothing , nothing , start, nothing ) :
141
- _range (start, step, stop, length)
139
+ _range_positional (start, step, stop, length)
142
140
143
141
function range (start, stop; length:: Union{Integer,Nothing} = nothing , step= nothing )
144
142
# For code clarity, the user must pass step or length
@@ -158,10 +156,15 @@ end
158
156
range (;start= nothing , stop= nothing , length:: Union{Integer, Nothing} = nothing , step= nothing ) =
159
157
_range (start, step, stop, length)
160
158
161
- range (length:: Integer ) = OneTo (length)
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)
162
165
163
166
_range (start:: Nothing , step:: Nothing , stop:: Nothing , len:: Nothing ) = range_error (start, step, stop, len)
164
- _range (start:: Nothing , step:: Nothing , stop:: Nothing , len:: Any ) = OneTo (len)
167
+ _range (start:: Nothing , step:: Nothing , stop:: Nothing , len:: Any ) = range_length (len)
165
168
_range (start:: Nothing , step:: Nothing , stop:: Any , len:: Nothing ) = range_stop (stop)
166
169
_range (start:: Nothing , step:: Nothing , stop:: Any , len:: Any ) = range_stop_length (stop, len)
167
170
_range (start:: Nothing , step:: Any , stop:: Nothing , len:: Nothing ) = range_error (start, step, stop, len)
@@ -177,6 +180,8 @@ _range(start::Any , step::Any , stop::Nothing, len::Any ) = range_start
177
180
_range (start:: Any , step:: Any , stop:: Any , len:: Nothing ) = range_start_step_stop (start, step, stop)
178
181
_range (start:: Any , step:: Any , stop:: Any , len:: Any ) = range_error (start, step, stop, len)
179
182
183
+ range_length (len:: Integer ) = OneTo (len)
184
+
180
185
range_stop (stop) = oneunit (stop): stop
181
186
range_stop (stop:: Integer ) = OneTo (stop)
182
187
0 commit comments