From eb77031e1f46b7c0d533294594baffd0fe30ffbb Mon Sep 17 00:00:00 2001 From: Thirumalai-Shaktivel Date: Tue, 23 Aug 2022 16:22:35 +0530 Subject: [PATCH 1/2] Store with_item value in the vector --- src/lpython/parser/semantics.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lpython/parser/semantics.h b/src/lpython/parser/semantics.h index 76fcbeb20a..a9b0c7cc00 100644 --- a/src/lpython/parser/semantics.h +++ b/src/lpython/parser/semantics.h @@ -336,7 +336,7 @@ static inline Vec convert_exprlist_to_withitem(Allocator &al, Vec v; v.reserve(al, expr_list.size()); for (size_t i=0; i Date: Tue, 23 Aug 2022 16:22:58 +0530 Subject: [PATCH 2/2] Add test and update the refs. --- tests/parser/with1.py | 3 +++ tests/reference/ast_new-with1-6c88c0f.json | 4 ++-- tests/reference/ast_new-with1-6c88c0f.stdout | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/parser/with1.py b/tests/parser/with1.py index ec586bc653..9d51a00045 100644 --- a/tests/parser/with1.py +++ b/tests/parser/with1.py @@ -18,3 +18,6 @@ with a, b, c as y, \ z: pass + +with tag('x'): + pass diff --git a/tests/reference/ast_new-with1-6c88c0f.json b/tests/reference/ast_new-with1-6c88c0f.json index 96e683460d..b9c5e2d9bf 100644 --- a/tests/reference/ast_new-with1-6c88c0f.json +++ b/tests/reference/ast_new-with1-6c88c0f.json @@ -2,11 +2,11 @@ "basename": "ast_new-with1-6c88c0f", "cmd": "lpython --show-ast --new-parser --no-color {infile} -o {outfile}", "infile": "tests/parser/with1.py", - "infile_hash": "797654839a99953c54122270601aae6c1b1cbfe590860d2bedec8d05", + "infile_hash": "41fb846455ede2c9626aeb5bf0684c65fb9a5483276df4838d8cfbf4", "outfile": null, "outfile_hash": null, "stdout": "ast_new-with1-6c88c0f.stdout", - "stdout_hash": "64d9bb656a0cbfeeea99504cdc0b86626f38797281a540fe7a853e1a", + "stdout_hash": "f87b5ff21f034fd3a14dca190406b993e681d64181ddf1a0b3e41fcd", "stderr": null, "stderr_hash": null, "returncode": 0 diff --git a/tests/reference/ast_new-with1-6c88c0f.stdout b/tests/reference/ast_new-with1-6c88c0f.stdout index f1ef80ff2e..7e41dfaa4c 100644 --- a/tests/reference/ast_new-with1-6c88c0f.stdout +++ b/tests/reference/ast_new-with1-6c88c0f.stdout @@ -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)] ())] []) +(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)] ())] [])