-
Notifications
You must be signed in to change notification settings - Fork 170
Added support for negative constant indexing in tuples #1534
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 all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1d9168b
Added support for negative indexing in tuples
anutosh491 2a9cd42
Added integration test
anutosh491 36562bf
Updated error messages
anutosh491 7d99710
Merge branch 'main' into branch05
anutosh491 3c620f2
Added semanticerror when val is nullptr
anutosh491 3ca6367
updated error message
anutosh491 57b27d4
Added tests to check for errors being thrown
anutosh491 bfd353f
added else block when type is not IntegerConstant
anutosh491 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
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,10 @@ | ||
from ltypes import i32, f64 | ||
|
||
def f(): | ||
t1: tuple[i32, f64, str] = (1, 2.0, "3") | ||
|
||
assert t1[-1] == "3" | ||
assert t1[-2] == 2.0 | ||
assert t1[-3] == 1 | ||
|
||
f() |
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,6 @@ | ||
def main0(): | ||
t: tuple[i32, i32, i32] = (1, 2, 3) | ||
x: i32 = -1 | ||
print(t[x]) | ||
|
||
main0() |
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,5 @@ | ||
def main0(): | ||
t: tuple[i32, i32, i32] = (1, 2, 3) | ||
print(t[-4]) | ||
|
||
main0() |
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_tuple2-b046610", | ||
"cmd": "lpython --show-asr --no-color {infile} -o {outfile}", | ||
"infile": "tests/errors/test_tuple2.py", | ||
"infile_hash": "84aa4ecdd21f5d633975d08f6927a7d336c47a31c2fd2bc42cae1c7b", | ||
"outfile": null, | ||
"outfile_hash": null, | ||
"stdout": null, | ||
"stdout_hash": null, | ||
"stderr": "asr-test_tuple2-b046610.stderr", | ||
"stderr_hash": "1e22bbde9c9fdc171314f1158dcac6bf6373d94e00c9878f66d7b667", | ||
"returncode": 2 | ||
} |
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,5 @@ | ||
semantic error: Runtime Indexing with tuple[i32, i32, i32] is not possible. | ||
--> tests/errors/test_tuple2.py:4:11 | ||
| | ||
4 | print(t[x]) | ||
| ^^^^ |
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_tuple3-19fa47f", | ||
"cmd": "lpython --show-asr --no-color {infile} -o {outfile}", | ||
"infile": "tests/errors/test_tuple3.py", | ||
"infile_hash": "cfa12cc4d8456bfd45e77cc49c5e8d2417181a1443cdaaf8b15c0528", | ||
"outfile": null, | ||
"outfile_hash": null, | ||
"stdout": null, | ||
"stdout_hash": null, | ||
"stderr": "asr-test_tuple3-19fa47f.stderr", | ||
"stderr_hash": "780d951c4bfa3476ee84d16d9a89c5a9255691b270bfb312d974608e", | ||
"returncode": 2 | ||
} |
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,5 @@ | ||
semantic error: Tuple index out of bounds | ||
--> tests/errors/test_tuple3.py:3:11 | ||
| | ||
3 | print(t[-4]) | ||
| ^^^^^ |
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
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.