Add error tests for mismatch in empty dtype#2307
Conversation
certik
left a comment
There was a problem hiding this comment.
I think this looks great.
I found a minor issue in the way the dimensions are printed. This can be fixed in subsequent PRs.
| --> tests/errors/arrays_05.py:6:5 | ||
| | | ||
| 6 | x: i16[5, 4] = empty([5, 3], dtype=int16) | ||
| | ^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ type mismatch ('i16[5][4]' and 'i16[5][3]') |
There was a problem hiding this comment.
I would write it as i16[5, 4] as in the source code, not i16[5][4].
There was a problem hiding this comment.
Do you also suggest to include the start value of the dimension? For example i16[0:5, 0:4]? I guess it is only helpful for the developers. For users it might confuse as python does not have lower_bounds. (Although it could be helpful in the case for LFortran if we reuse this printing mechanism/function there.)
We can also include the start value of the dimension later (when we have more experience with error messages or user feedback).
There was a problem hiding this comment.
For Python I would print it as just i16[5, 4]. For LFortran we use a different method to print the type, and there indeed we have an option to print the dimension in the usual Fortran notation --- depending on the context, sometimes the lower dimension matters, sometimes it doesn't.
fixes #2294 (review)