Improve error when indexing is interpreted as a typed comprehension#49939
Improve error when indexing is interpreted as a typed comprehension#49939LilithHafner merged 7 commits intoJuliaLang:masterfrom
Conversation
This adds a special error for indexing that gets resolved as a typed comprehension.
LilithHafner
left a comment
There was a problem hiding this comment.
Thank you for making a PR! I left some minor comments, but this looks like a good implementation design and it is already better than what we have in 1.9 and master.
f2530f4 to
39faddb
Compare
|
Thanks for your comments. Requested changes are addressed. |
LilithHafner
left a comment
There was a problem hiding this comment.
The tests look good to me and the error hint, while long, seems reasonable.
Suggested change during review Co-authored-by: Lilith Orion Hafner <[email protected]>
Co-authored-by: Lilith Orion Hafner <[email protected]>
LilithHafner
left a comment
There was a problem hiding this comment.
Lovely! Thank you so much :) I'll merge this tomorrow unless @jishnub or someone else objects.
| # interpreted as a typed concatenation. (issue #49676) | ||
| typed_hcat(::AbstractArray, other...) = throw(ArgumentError("It is unclear whether you \ | ||
| intend to perform an indexing operation or typed concatenation. If you intend to \ | ||
| perform indexing (v[1 + 2]) insert missing operator or adjust spacing to clarify. \ |
There was a problem hiding this comment.
Just a minor suggestion: it'll be easier to read if there's a comma after perform indexing (v[1 + 2]) and similarly after typed concatenation (T[1 2]). I'd also move adjust spacing before insert missing operator, as this is probably the common tripping hazard here.
There was a problem hiding this comment.
Makes sense. Updated.
|
Looks good to me, I've left a minor comment. Thanks for the PR! |
|
Thanks! |
When indexing into an array, writing
vec[i +1]is interpreted as a typed comprehensionvec[i 1]. Becausevecis not a type, it causes a unhelpful error.This adds a new error message for this case. Example:
This is my first PR here, please let me know if I can make any improvements.
See #49676