Skip to content
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

Handle the case where start is greater than end in list.index() #2022

Merged
merged 2 commits into from
Jun 25, 2023

Conversation

faze-geek
Copy link
Contributor

A rather unlikely edge case -

def f():
    lst :list[i32] = [1, 2, 3]
    print(lst.index(2,2,1))

f()

On master :

(lp) C:\Users\kunni\lpython>python try.py
Traceback (most recent call last):
  File "C:\Users\kunni\lpython\try.py", line 5, in <module>
    f()
  File "C:\Users\kunni\lpython\try.py", line 3, in f
    print(lst.index(2,2,1))
ValueError: 2 is not in list

(lp) C:\Users\kunni\lpython>src\bin\lpython try.py
2

On branch :

(lp) C:\Users\kunni\lpython>src\bin\lpython try.py
ValueError: The list does not contain the element: 2

Copy link
Contributor

@certik certik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that looks good, thanks!

@certik certik merged commit e2b03ca into lcompilers:main Jun 25, 2023
8 checks passed
@faze-geek faze-geek deleted the index branch June 25, 2023 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants