-
Notifications
You must be signed in to change notification settings - Fork 159
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
Implement Set #91
Merged
Merged
Implement Set #91
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
7e0cea8
ASR.asdl: Add `ConstantSet` as an `expr`
namannimmo10 589258c
Implement visitor: `visit_Set`
namannimmo10 ca15327
Modify src/runtime/lpython_parser.py
namannimmo10 82f06bf
Modify `LFORTRAN_ASSERT` check
namannimmo10 1997034
Register the test for Set
namannimmo10 f61f65e
Rename elts to elements
namannimmo10 b71238b
ASR.asdl: Create a new type - Set
namannimmo10 3411459
Make `Set` the type of `ConstantSet`
namannimmo10 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
Register the test for Set
- Loading branch information
commit 1997034f563487df015f69fdf95dcca67d89b9ec
There are no files selected for viewing
This file contains 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-set1-b7b913a", | ||
"cmd": "lpython --show-asr --no-color {infile} -o {outfile}", | ||
"infile": "tests/set1.py", | ||
"infile_hash": "9daf37483fb6f1523007506236ce239db1f9c56a31c5e028bbecff0b", | ||
"outfile": null, | ||
"outfile_hash": null, | ||
"stdout": "asr-set1-b7b913a.stdout", | ||
"stdout_hash": "9dde6562a377c4220974f0663dcabb38f57023373053bb00c19397ba", | ||
"stderr": null, | ||
"stderr_hash": null, | ||
"returncode": 0 | ||
} |
This file contains 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 @@ | ||
(TranslationUnit (SymbolTable 1 {test_Set: (Subroutine (SymbolTable 2 {a: (Variable 2 a Local () () Default (Integer 4 []) Source Public Required .false.), b: (Variable 2 b Local () () Default (Integer 4 []) Source Public Required .false.)}) test_Set [] [(= (Var 2 a) (ConstantSet [(ConstantInteger 1 (Integer 4 [])) (ConstantInteger 2 (Integer 4 [])) (ConstantInteger 3 (Integer 4 []))] (Integer 4 [])) ()) (= (Var 2 a) (ConstantSet [(ConstantInteger 2 (Integer 4 [])) (ConstantInteger 3 (Integer 4 [])) (ConstantInteger 4 (Integer 4 [])) (ConstantInteger 5 (Integer 4 [])) (ConstantInteger 5 (Integer 4 []))] (Integer 4 [])) ()) (= (Var 2 a) (ConstantSet [(ConstantString "a" (Character 1 1 () [])) (ConstantString "b" (Character 1 1 () [])) (ConstantString "c" (Character 1 1 () []))] (Character 1 1 () [])) ()) (= (Var 2 b) (ArrayRef 2 a [(() (ConstantInteger 0 (Integer 4 [])) ())] (Integer 4 []) ()) ())] Source Public Implementation () .false. .false.)}) []) |
This file contains 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": "ast-set1-ebd6ee0", | ||
"cmd": "lpython --show-ast --no-color {infile} -o {outfile}", | ||
"infile": "tests/set1.py", | ||
"infile_hash": "9daf37483fb6f1523007506236ce239db1f9c56a31c5e028bbecff0b", | ||
"outfile": null, | ||
"outfile_hash": null, | ||
"stdout": "ast-set1-ebd6ee0.stdout", | ||
"stdout_hash": "8c1cad9ac254b1847c30e26721e705d4db36fca6316e0f4e870f06a0", | ||
"stderr": null, | ||
"stderr_hash": null, | ||
"returncode": 0 | ||
} |
This file contains 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 @@ | ||
(Module [(FunctionDef test_Set ([] [] [] [] [] [] []) [(AnnAssign (Name a Store) (Name i32 Load) () 1) (AnnAssign (Name b Store) (Name i32 Load) () 1) (Assign [(Name a Store)] (Set [(ConstantInt 1 ()) (ConstantInt 2 ()) (ConstantInt 3 ())]) ()) (Assign [(Name a Store)] (Set [(ConstantInt 2 ()) (ConstantInt 3 ()) (ConstantInt 4 ()) (ConstantInt 5 ()) (ConstantInt 5 ())]) ()) (Assign [(Name a Store)] (Set [(ConstantStr "a" ()) (ConstantStr "b" ()) (ConstantStr "c" ())]) ()) (Assign [(Name b Store)] (Subscript (Name a Load) (ConstantInt 0 ()) Load) ())] [] () ())] []) |
This file contains 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 @@ | ||
def test_Set(): | ||
a: i32 | ||
b: i32 | ||
|
||
a = {1, 2, 3} | ||
a = {2, 3, 4, 5, 5} | ||
a = {"a", "b", "c"} | ||
# a = {-1, -2, "c"} -> semantic error for now | ||
b = a[0] | ||
Smit-create marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains 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.
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.
All these should give an error message that "Set[i32] (or character) cannot be assigned to i32".
Then let's add tests like:
And we need to improve the assignment to do this check.