Skip to content

Commit d211ad2

Browse files
Merge pull request #1015 from Thirumalai-Shaktivel/fix_with_stmt
2 parents 1556ade + a58b581 commit d211ad2

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

src/lpython/parser/semantics.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ static inline Vec<withitem_t> convert_exprlist_to_withitem(Allocator &al,
336336
Vec<withitem_t> v;
337337
v.reserve(al, expr_list.size());
338338
for (size_t i=0; i<expr_list.size(); i++) {
339-
WITH_ITEM(l, EXPR(expr_list[i]), nullptr);
339+
v.push_back(al, WITH_ITEM(l, EXPR(expr_list[i]), nullptr));
340340
}
341341
return v;
342342
}

tests/parser/with1.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,6 @@
1818
with a, b, c as y, \
1919
z:
2020
pass
21+
22+
with tag('x'):
23+
pass

tests/reference/ast_new-with1-6c88c0f.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
"basename": "ast_new-with1-6c88c0f",
33
"cmd": "lpython --show-ast --new-parser --no-color {infile} -o {outfile}",
44
"infile": "tests/parser/with1.py",
5-
"infile_hash": "797654839a99953c54122270601aae6c1b1cbfe590860d2bedec8d05",
5+
"infile_hash": "41fb846455ede2c9626aeb5bf0684c65fb9a5483276df4838d8cfbf4",
66
"outfile": null,
77
"outfile_hash": null,
88
"stdout": "ast_new-with1-6c88c0f.stdout",
9-
"stdout_hash": "64d9bb656a0cbfeeea99504cdc0b86626f38797281a540fe7a853e1a",
9+
"stdout_hash": "f87b5ff21f034fd3a14dca190406b993e681d64181ddf1a0b3e41fcd",
1010
"stderr": null,
1111
"stderr_hash": null,
1212
"returncode": 0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
(Module [(With [((Call (Name A Load) [] []) (Name a Store)) ((Call (Name B Load) [] []) (Name b Store))] [(Expr (Call (Name f Load) [(Name a Load) (Name b Load)] []))] ()) (With [((Call (Name A Load) [] []) (Name a Store)) ((Call (Name B Load) [(Name a Load)] []) (Name b Store)) ((Call (Name C Load) [(Name a Load) (Name b Load)] []) (Name c Store))] [(Expr (Call (Name f Load) [(Name a Load) (Name c Load)] []))] ()) (With [((Call (Name open Load) [(ConstantStr "examples/expr2.py" ()) (ConstantStr "r" ())] []) (Name file Store))] [(Assign [(Name x Store)] (Call (Attribute (Name file Load) read Load) [] []) ())] ()) (With [((Call (Name open Load) [(ConstantEllipsis ())] []) (Name f Store))] [(Expr (ConstantEllipsis ()))] ()) (With [((Call (Name open Load) [(ConstantStr "examples/expr2.py" ()) (ConstantStr "r" ())] []) (Name file Store))] [(Assign [(Name x Store)] (Call (Attribute (Name file Load) read Load) [] []) ())] ()) (With [((Tuple [(Name a Load) (Name b Load) (Name c Load)] Load) (Tuple [(Name y Load) (Name z Load)] Store))] [(Pass)] ())] [])
1+
(Module [(With [((Call (Name A Load) [] []) (Name a Store)) ((Call (Name B Load) [] []) (Name b Store))] [(Expr (Call (Name f Load) [(Name a Load) (Name b Load)] []))] ()) (With [((Call (Name A Load) [] []) (Name a Store)) ((Call (Name B Load) [(Name a Load)] []) (Name b Store)) ((Call (Name C Load) [(Name a Load) (Name b Load)] []) (Name c Store))] [(Expr (Call (Name f Load) [(Name a Load) (Name c Load)] []))] ()) (With [((Call (Name open Load) [(ConstantStr "examples/expr2.py" ()) (ConstantStr "r" ())] []) (Name file Store))] [(Assign [(Name x Store)] (Call (Attribute (Name file Load) read Load) [] []) ())] ()) (With [((Call (Name open Load) [(ConstantEllipsis ())] []) (Name f Store))] [(Expr (ConstantEllipsis ()))] ()) (With [((Call (Name open Load) [(ConstantStr "examples/expr2.py" ()) (ConstantStr "r" ())] []) (Name file Store))] [(Assign [(Name x Store)] (Call (Attribute (Name file Load) read Load) [] []) ())] ()) (With [((Tuple [(Name a Load) (Name b Load) (Name c Load)] Load) (Tuple [(Name y Load) (Name z Load)] Store))] [(Pass)] ()) (With [((Call (Name tag Load) [(ConstantStr "x" ())] []) ())] [(Pass)] ())] [])

0 commit comments

Comments
 (0)