-
Notifications
You must be signed in to change notification settings - Fork 171
Add support for item access from Const
data-structures
#2579
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
5d40049
Add support for accessing items from data-structures within `Const`
kmr-srbh 2fb304a
Update type checking logic for `Const dict`
kmr-srbh 416d1c3
Minor formatting change
kmr-srbh 7077516
Merge branch 'main' into support-const-access
kmr-srbh e622a9d
Handle negative indices for `const list` and minor formatting changes
kmr-srbh 1a3a5d5
Add tests
kmr-srbh 1f74255
Update test references
kmr-srbh 20aa660
Heavily simplify handling `const`
kmr-srbh 510b65b
Merge branch 'main' into support-const-access
kmr-srbh 32b691e
Tests: Add compile time test
kmr-srbh 0553c04
Merge branch 'main' into support-const-access
kmr-srbh c8a5020
Merge branch 'main' into support-const-access
kmr-srbh b62f675
Merge branch 'main' into support-const-access
kmr-srbh 5ebc24f
Merge branch 'main' into support-const-access
kmr-srbh cb8a0f2
Remove calls to `type_get_past_const()`
kmr-srbh 9803138
Tests: Update test references
kmr-srbh d8d82ea
Remove extra newline
kmr-srbh 55ba905
Delete tests/reference/asr-test_const_access-82a9a24.json
kmr-srbh 89ad7e3
Delete tests/reference/asr-test_const_access-82a9a24.stdout
kmr-srbh 36a1716
Delete tests/reference/asr-test_const_str_access-59ff543.stderr
kmr-srbh b3bbe78
Delete tests/reference/asr-test_const_tuple_access-0d4c6df.json
kmr-srbh 3da9626
Delete tests/reference/asr-test_const_tuple_access-0d4c6df.stderr
kmr-srbh 733541e
Delete tests/reference/asr-test_const_str_access-59ff543.json
kmr-srbh 41514a2
Formatting changes
kmr-srbh ed8662d
Tests: Add test to CMakeLists and update error references
kmr-srbh e69f52a
Merge branch 'main' into support-const-access
kmr-srbh 334f429
Update asr_to_llvm.cpp
kmr-srbh 251b5d4
Undo formatting changes
kmr-srbh be48acf
Undo formatting changes
kmr-srbh 2620956
Revert throwing error for `Const` annotated tuples and strings
kmr-srbh c0407b5
Tests: Remove error references
kmr-srbh f489720
Remove redundant visitor
kmr-srbh 970ce8c
Undo moving `index`
kmr-srbh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from lpython import i32, str, list, dict, Const | ||
|
||
|
||
def test_const_access(): | ||
CONST_LIST: Const[list[i32]] = [1, 2, 3, 4, 5] | ||
CONST_DICTIONARY: Const[dict[str, i32]] = {"a": 1, "b": 2, "c": 3} | ||
|
||
assert CONST_LIST[0] == 1 | ||
assert CONST_LIST[-2] == 4 | ||
|
||
assert CONST_DICTIONARY["a"] == 1 | ||
|
||
|
||
test_const_access() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from lpython import str, Const | ||
|
||
|
||
def test_const_str_access(): | ||
CONST_STRING: Const[str] = "Hello, LPython!" | ||
|
||
|
||
test_const_str_access() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from lpython import str, tuple, Const | ||
|
||
|
||
def test_const_tuple_access(): | ||
CONST_TUPLE: Const[tuple[str, str, str]] = ("hello", "LPython", "!") | ||
|
||
|
||
test_const_tuple_access() | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"basename": "asr-test_const_access-82a9a24", | ||
"cmd": "lpython --show-asr --no-color {infile} -o {outfile}", | ||
"infile": "tests/../integration_tests/test_const_access.py", | ||
"infile_hash": "c25c7c1c19db38e066b47dc2891abaa5ddd7379b4df07892cebb94e3", | ||
"outfile": null, | ||
"outfile_hash": null, | ||
"stdout": "asr-test_const_access-82a9a24.stdout", | ||
"stdout_hash": "a98657aca0fefd42749ce13d47c09daf48deed01ec24170d242f5ee3", | ||
"stderr": null, | ||
"stderr_hash": null, | ||
"returncode": 0 | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.