Skip to content

Commit 56ce565

Browse files
authored
Fix removing parens for in-place objects fix #331 (#335)
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 10241cd commit 56ce565

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
@@ -2979,7 +2979,12 @@ class parser
29792979
}
29802980
expr_list->close_paren = &curr();
29812981
next();
2982-
if (curr().type() != lexeme::Semicolon) {
2982+
if (
2983+
curr().type() != lexeme::Semicolon
2984+
&& curr().type() != lexeme::RightParen
2985+
&& curr().type() != lexeme::RightBracket
2986+
&& curr().type() != lexeme::Comma
2987+
) {
29832988
expr_list->inside_initializer = false;
29842989
}
29852990
n->expr = std::move(expr_list);

0 commit comments

Comments
 (0)