@@ -83,6 +83,7 @@ module IteratorsMD
83
83
CartesianIndex {N} (index:: Integer... ) where {N} = CartesianIndex {N} (index)
84
84
CartesianIndex {N} () where {N} = CartesianIndex {N} (())
85
85
# Un-nest passed CartesianIndexes
86
+ CartesianIndex {N} (index:: CartesianIndex{N} ) where {N} = index
86
87
CartesianIndex (index:: Union{Integer, CartesianIndex} ...) = CartesianIndex (flatten (index))
87
88
flatten (:: Tuple{} ) = ()
88
89
flatten (I:: Tuple{Any} ) = Tuple (I[1 ])
@@ -166,6 +167,19 @@ module IteratorsMD
166
167
Base. iterate (:: CartesianIndex ) =
167
168
error (" iteration is deliberately unsupported for CartesianIndex. Use `I` rather than `I...`, or use `Tuple(I)...`" )
168
169
170
+ # ranges are deliberately disabled to prevent ambiguities with the colon constructor
171
+ Base. range_start_step_length (start:: CartesianIndex , step:: CartesianIndex , len:: Integer ) =
172
+ error (" range with a specified length is deliberately unsupported for CartesianIndex arguments." *
173
+ " Use StepRangeLen($start , $step , $len ) to construct this range" )
174
+
175
+ # show is special-cased to avoid the start:stop:step display,
176
+ # which constructs a CartesianIndices
177
+ # See #50784
178
+ function show (io:: IO , r:: StepRangeLen{<:CartesianIndex} )
179
+ print (io, " StepRangeLen(" , first (r), " , " ,
180
+ step (r), " , " , length (r), " )" )
181
+ end
182
+
169
183
# Iteration
170
184
const OrdinalRangeInt = OrdinalRange{Int, Int}
171
185
"""
0 commit comments