Skip to content

Commit

Permalink
Emit explanatory error message for iteration on CartesianIndex
Browse files Browse the repository at this point in the history
Fixes #23982
  • Loading branch information
timholy committed Oct 23, 2017
1 parent fc6b2ba commit 870ce0e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions base/multidimensional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ module IteratorsMD
return ni
end

# Iteration over the elements of CartesianIndex cannot be supported until its length can be inferred,
# see #23719
Base.start(::CartesianIndex) =
error("iteration is deliberately unsupported for CartesianIndex. Use `I` rather than `I...`, or use `Tuple(I)...`")

# Iteration
"""
CartesianRange(sz::Dims) -> R
Expand Down

0 comments on commit 870ce0e

Please sign in to comment.