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. |
I am adding the tests in a while. |
|
@Shaikh-Ubaid This PR is now ready. |
|
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 <[email protected]>
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 [email protected]:kmr-srbh/lpython.git const-list-attributes --rebaseor simply checkout a new copy of the remote branch and work on it if you are comfortable that way. |
|
Please mark it as "Ready for review" when ready. I will do a final review then. |
ubaidsk
left a comment
There was a problem hiding this comment.
It looks great! Thanks for this! Amazing work!
Fixes #2584
The following changes were made:
list.append- throw aSemanticErrorstating changes not allowedlist.remove- throw aSemanticErrorstating changes not allowedlist.count- fetch the element countlist.index- fetch the element indexlist.reverse- throw aSemanticErrorstating changes not allowedlist.pop- throw aSemanticErrorstating changes not allowedlist.clear- throw aSemanticErrorstating changes not allowedlist.insert- throw aSemanticErrorstating changes not allowedcount()
append()
Other functions work accordingly.