lfortran / lfortran

Official main repository for LFortran

Home Page:https://lfortran.org/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Array reverse slice

Euler-37 opened this issue · comments

program main
    implicit none
    integer::a(2)
    a=[1,2]
    a(1:2)=a(2:1:-1)
    write(*,*)a
end program main
$ lfortran --version
LFortran version: 0.35.0
Platform: Windows
Default target: x86_64-pc-windows-msvc
$ lfortran 1.f90
2
2
$ gfortran 1.f90 && a.exe
  2  1

bug for reverse array slice

Good catch, thanks!

I think this issue happens because there is an assignment to an ArraySection which is itself. e.g. the below program works:

program main
    implicit none
    integer :: a(2)
    integer :: b(2)
    a = [1,2]
    b = [1,2]
    a(1:2) = b(2:1:-1) 
    print *, a !> output is 2, 1
end program main

I'll try to see if I can fix this issue. The problem is in array_op pass