-
Notifications
You must be signed in to change notification settings - Fork 162
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
Add support for list
methods with Const
#2570
Add support for list
methods with Const
#2570
Conversation
I am not sure why the tests fail. It passes when manually executing the file. |
I guess you need to update the references. |
I have not written any new tests @anutosh491. These are the old ones which are failing. I made changes to the |
@kmr-srbh what specific test-case or example that fails with LPython (of current PS: Can you point to the issue that this PR fixes? |
Please see #2567 (comment) |
Why don't you create an issue first and list all the bugs related to That would help highlight the contributions made and also make it simpler to review. Thanks! |
I am opening an issue. I will keep it in mind for future bugs. Thank you! |
Please mark this PR ready for review once it is ready. |
I am adding the tests @Thirumalai-Shaktivel and @Shaikh-Ubaid. In the meantime, I request you to review this. In accordance to the simplification advised by @Shaikh-Ubaid , I have simplified all such expressions. I have tested the changes locally. I am doing the same for the dictionary PR too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I shared two comments above. I think the PR is getting in shape. Thanks for working on this @kmr-srbh!
For each SemanticError()
newly added in this PR, please add an error reference test.
I am adding the tests in a while. |
@Shaikh-Ubaid This PR is now ready. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the PR is in good direction. Great work @kmr-srbh!
Please mark it as "Ready for review" when ready. |
I get this error when running the tests from from lpython import i32, list, str, Const
def test_const_list():
CONST_INTEGER_LIST: Const[list[i32]] = [1, 2, 3, 4, 5, 1]
assert CONST_INTEGER_LIST.count(1) == 2
assert CONST_INTEGER_LIST.index(1) == 0
CONST_STRING_LIST: Const[list[str]] = ["ALPHA", "BETA", "RELEASE"]
assert CONST_STRING_LIST.count("ALPHA") == 1
assert CONST_STRING_LIST.index("RELEASE") == 2
test_const_list() code generation error: asr_to_llvm: module failed verification. Error:
Stored value type does not match pointer operand type!
store %list* %const_list, %list* %CONST_INTEGER_LIST, align 8
%list = type { i32, i32, i32* }Stored value type does not match pointer operand type!
store %list.0* %const_list1, %list.0* %CONST_STRING_LIST, align 8
%list.0 = type { i32, i32, i8** } |
Co-authored-by: Shaikh Ubaid <shaikhubaid769@gmail.com>
a7c1115
to
d202999
Compare
I attempted fixing it. Let's see if the CI passes. |
26c4e10
to
66c288f
Compare
I rebased this PR on main branch. Hence, to push to this branch further, you would need to first pull the changes from this branch with git pull git@github.com:kmr-srbh/lpython.git const-list-attributes --rebase or simply checkout a new copy of the remote branch and work on it if you are comfortable that way. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please mark it as "Ready for review" when ready. I will do a final review then. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks great! Thanks for this! Amazing work!
Fixes #2584
The following changes were made:
list.append
- throw aSemanticError
stating changes not allowedlist.remove
- throw aSemanticError
stating changes not allowedlist.count
- fetch the element countlist.index
- fetch the element indexlist.reverse
- throw aSemanticError
stating changes not allowedlist.pop
- throw aSemanticError
stating changes not allowedlist.clear
- throw aSemanticError
stating changes not allowedlist.insert
- throw aSemanticError
stating changes not allowedcount()
append()
Other functions work accordingly.