Skip to content

Commit 85403bc

Browse files
committed
Fix removing parens for in-place objects fix #331
That should cover cases: ```cpp f1(:std::vector=(1,2,3)); f2(:std::vector=(1,2,3),:std::vector=(4,5)); ar[:index=(1,2)]; ar2[:index=(1,2), :index=(2,1)]; ``` that will generate: ```cpp f1(std::vector{1, 2, 3}); f2(std::vector{1, 2, 3}, std::vector{4, 5}); cpp2::assert_in_bounds(ar, index{1, 2}); cpp2::assert_in_bounds(ar2, index{1, 2}, index{2, 1}); ```
1 parent a9f64ba commit 85403bc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

source/parse.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2882,7 +2882,12 @@ class parser
28822882
}
28832883
expr_list->close_paren = &curr();
28842884
next();
2885-
if (curr().type() != lexeme::Semicolon) {
2885+
if (
2886+
curr().type() != lexeme::Semicolon
2887+
&& curr().type() != lexeme::RightParen
2888+
&& curr().type() != lexeme::RightBracket
2889+
&& curr().type() != lexeme::Comma
2890+
) {
28862891
expr_list->inside_initializer = false;
28872892
}
28882893
n->expr = std::move(expr_list);

0 commit comments

Comments
 (0)