Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit explanatory error message for iteration on CartesianIndex #24284

Merged
merged 1 commit into from
Nov 3, 2017

Conversation

timholy
Copy link
Sponsor Member

@timholy timholy commented Oct 23, 2017

As suggested in #23982. Sometimes these messages are helpful, but they can occasionally cause problems. In this case the most confusing part of the message would be if someone hit this in the context of

julia> I = CartesianIndex(1,2,3)
CartesianIndex(1, 2, 3)

julia> for i in I
           @show i
       end
ERROR: iteration is deliberately unsupported for CartesianIndex. Use `I` rather than `I...`, or use `Tuple(I)...`

and the user might wonder what splatting has to do with it. Nevertheless I suspect that splatting is how most people hit this issue.

But I am not attached to this. I've also deliberately not added a test for this behavior, since once the length can be inferred we will want to support iteration over the elements of CartesianIndex.

@timholy
Copy link
Sponsor Member Author

timholy commented Nov 2, 2017

Barring objections I'll merge soon.

@timholy timholy changed the title RFC: emit explanatory error message for iteration on CartesianIndex Emit explanatory error message for iteration on CartesianIndex Nov 3, 2017
@timholy timholy merged commit fe13a16 into master Nov 3, 2017
@timholy timholy deleted the teh/cartindex branch November 3, 2017 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant