lpython
lpython copied to clipboard
`List.reverse()` should not return anything
I came across some inconsistencies with python while using reverse operation, I am not sure what should be expected with lpython as a None type is not supported here.
Snippet 1 - Maybe this can be caught as redefinition of a and not allowed?
def f():
a :list[i32]= [1, 2, 3, 4]
a = a.reverse()
print(a)
f()
(lp) C:\Users\kunni\lpython>python try.py
None
(lp) C:\Users\kunni\lpython>src\bin\lpython try.py
[4, 3, 2, 1]
Snippet 2 - Here an empty list gets returned.
def f():
a :list[i32]= [1, 2, 3, 4]
b :list[i32] = a.reverse()
print(b)
f()
(lp) C:\Users\kunni\lpython>python try.py
None
(lp) C:\Users\kunni\lpython>src\bin\lpython try.py
[]