Skip to content

Commit

Permalink
Fix for list_comp, add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
krshrimali committed Jul 17, 2022
1 parent afc4804 commit 1fac76b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lpython/parser/parser.yy
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ id_list
id_item
: id_list { $$ = ID_TUPLE_01($1, @$); }
| id_list "," { $$ = ID_TUPLE_03($1, @$); }
| "(" id ")" { $$ = $2; }
| "(" id_list "," ")" { $$ = ID_TUPLE_03($2, @$); }
| "(" id_list "," id ")" { $$ = ID_TUPLE_01(TUPLE_($2, $4), @$); }
;
Expand Down
4 changes: 4 additions & 0 deletions tests/parser/comprehension1.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@
distance_orig = [x**2 + y**2 + z**2 for x, y, z in points]

odd_elements = [i for i in main_list if i & 1]

first_ten_elements = [i for (i) in range(10)]

another_ten_elements = [(i) for (i) in range(10)]

0 comments on commit 1fac76b

Please sign in to comment.