-
Notifications
You must be signed in to change notification settings - Fork 170
Array assignment fails #1599
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
Comments
1 task
The following seems to work: from lpython import f32
from numpy import empty, float32
def main():
a: f32[3] = empty(3, dtype=float32)
b: f32[3] = empty(3, dtype=float32)
a[0] = f32(1)
a[1] = f32(2)
a[2] = f32(3)
b = a
# b[:] = a[:]
print(a, b)
main() We need to support |
I checked this in LFortran: program name
implicit none
integer:: x(2) = [1,2]
integer:: y(2)
y(:) = x(:)
print *, x, y
end program name $ lfortran examples/expr2.f90
1 2
0 0
$ gfortran examples/expr2.f90 && ./a.out
1 2 1 2 It seems both have the same issue .i.e., (=
(ArraySection
(Var 2 y)
[((ArrayBound
(Var 2 y)
(IntegerConstant 1 (Integer 4))
(Integer 4)
LBound
(IntegerConstant 1 (Integer 4))
)
(ArrayBound
(Var 2 y)
(IntegerConstant 1 (Integer 4))
(Integer 4)
UBound
(IntegerConstant 2 (Integer 4))
)
(IntegerConstant 1 (Integer 4)))]
(Array
(Integer 4)
[(()
())]
DescriptorArray
)
()
)
(ArraySection
(Var 2 x)
[((ArrayBound
(Var 2 x)
(IntegerConstant 1 (Integer 4))
(Integer 4)
LBound
(IntegerConstant 1 (Integer 4))
)
(ArrayBound
(Var 2 x)
(IntegerConstant 1 (Integer 4))
(Integer 4)
UBound
(IntegerConstant 2 (Integer 4))
)
(IntegerConstant 1 (Integer 4)))]
(Array
(Integer 4)
[(()
())]
DescriptorArray
)
()
)
()
) After arrayop pass (=>
(Var 2 __libasr__created__var__0__array_section_pointer_)
(ArraySection
(Var 2 x)
[((ArrayBound
(Var 2 x)
(IntegerConstant 1 (Integer 4))
(Integer 4)
LBound
(IntegerConstant 1 (Integer 4))
)
(ArrayBound
(Var 2 x)
(IntegerConstant 1 (Integer 4))
(Integer 4)
UBound
(IntegerConstant 2 (Integer 4))
)
(IntegerConstant 1 (Integer 4)))]
(Array
(Integer 4)
[(()
())]
DescriptorArray
)
()
)
) |
program name
implicit none
integer:: x(2) = [1,2]
integer:: y(2)
y = x(:)
print *, x, y
end program name LFortran $ lfortran examples/expr2.f90
1 2
0 0 @czgdp1807, I came across this: #1599 (comment) issue again in LFortran! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
gives:
The text was updated successfully, but these errors were encountered: