Let's take an example of the StringSection node. It was introduced in lpython and now it is also used in lfortran. The current StringSection in the LLVM backend is implemented based on 0-based indexing and so works for lpython but fails for lfortran. 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:
def f():
s: str = "checking"
r: str = s[1:4]
print(r)
f()
Works fine:
% lpython b.py
hec
% python b.py
hec
Fortran
program main
implicit none
character(len=10) :: b
b = "checking"
print *, b(1:4)
end program main
Fails:
% lfortran a.f90
hec
% gfortran a.f90 -o a.out && ./a.out
chec
This should also be kept the same for loops etc.
cc @certik @czgdp1807
Let's take an example of the
StringSectionnode. It was introduced inlpythonand now it is also used inlfortran. The currentStringSectionin the LLVM backend is implemented based on 0-based indexing and so works forlpythonbut 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