-
Notifications
You must be signed in to change notification settings - Fork 2
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
Fix ASR indexing - 0 based/1 based? #11
Comments
Yes, I think we have an issue for this somewhere. We need to pick either 0 or 1 for these in ASR. For arrays we always include the first index, so there is no problem. For the rest of the nodes I would pick and probably 0, as that makes it easier on the LLVM backend. |
Okay, I think we should probably go with 1 based indexing everywhere to keep it uniform and probably fix that in |
I would pick 0 for the following reasons:
The only downside is that our future Fortran backend has to fix up string indexing. If we pick 1, then Fortran is fine, but we have to adjust indexing in Python a lot. |
Let's take an example of the
StringSection
node. It was introduced inlpython
and now it is also used inlfortran
. The currentStringSection
in the LLVM backend is implemented based on 0-based indexing and so works forlpython
but fails forlfortran
. We need to have these fixes in ASR so that each front end follows the same indexing in every node.See the following snippet in python:
Works fine:
Fortran
Fails:
This should also be kept the same for loops etc.
cc @certik @czgdp1807
The text was updated successfully, but these errors were encountered: