Skip to content

Commit cf66162

Browse files
committed
fix: revert hsutter#1092
1 parent 774b373 commit cf66162

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

regression-tests/pure2-bugfix-for-nested-lists.cpp2

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,9 @@ main: () = {
2525
// Still parentheses (for now?)
2626
assert((:std::vector = (17, 29)).size() == 2);
2727
}
28+
29+
issue_1283: () = {
30+
arr: std::array<std::string, 10> = ();
31+
f: MyFunctor = ("Some initial value");
32+
std::ranges::generate(arr, :() (f&$*)());
33+
}

regression-tests/test-results/pure2-bugfix-for-nested-lists.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ public: explicit point();
3434

3535
auto main() -> int;
3636

37+
#line 29 "pure2-bugfix-for-nested-lists.cpp2"
38+
auto issue_1283() -> void;
39+
3740
//=== Cpp2 function definitions =================================================
3841

3942
#line 1 "pure2-bugfix-for-nested-lists.cpp2"
@@ -84,3 +87,10 @@ auto main() -> int{
8487
if (cpp2::cpp2_default.is_active() && !(CPP2_UFCS(size)((std::vector{17, 29})) == 2) ) { cpp2::cpp2_default.report_violation(""); }
8588
}
8689

90+
#line 29 "pure2-bugfix-for-nested-lists.cpp2"
91+
auto issue_1283() -> void{
92+
std::array<std::string,10> arr {};
93+
MyFunctor f {"Some initial value"};
94+
std::ranges::generate(cpp2::move(arr), [_0 = (&f)]() mutable -> auto { return (*cpp2::impl::assert_not_null(_0))(); });
95+
}
96+

source/parse.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,6 @@ struct expression_list_node
699699
token const* open_paren = {};
700700
token const* close_paren = {};
701701
bool inside_initializer = false;
702-
bool default_initializer = false;
703702

704703
struct term {
705704
passing_style pass = {};
@@ -5772,7 +5771,6 @@ class parser
57725771
};
57735772
mutable std::vector<function_body_extent> function_body_extents;
57745773
mutable bool is_function_body_extents_sorted = false;
5775-
bool is_inside_call_expr = false;
57765774

57775775
public:
57785776
auto is_within_function_body(source_position p) const
@@ -6139,8 +6137,6 @@ class parser
61396137
expr_list->inside_initializer = false;
61406138
}
61416139
n->expression_list_is_fold_expression = expr_list->is_fold_expression();
6142-
expr_list->default_initializer =
6143-
is_inside_call_expr && std::empty(expr_list->expressions);
61446140

61456141
n->expr = std::move(expr_list);
61466142
return n;
@@ -6296,9 +6292,7 @@ class parser
62966292
// Next should be an expression-list followed by a ')'
62976293
// If not, then this wasn't a call expression so backtrack to
62986294
// the '(' which will be part of the next grammar production
6299-
is_inside_call_expr = true;
63006295
term.expr_list = expression_list(term.op, lexeme::RightParen, true);
6301-
is_inside_call_expr = false;
63026296

63036297
if (
63046298
term.expr_list

source/to_cpp1.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4074,13 +4074,6 @@ class cppfront
40744074
!(n.inside_initializer && current_declarations.back()->initializer->position() != n.open_paren->position())
40754075
;
40764076

4077-
if (n.default_initializer) {
4078-
if (add_parens) {
4079-
printer.print_cpp2("{}", n.position());
4080-
}
4081-
return;
4082-
}
4083-
40844077
if (add_parens) {
40854078
printer.print_cpp2( *n.open_paren, n.position());
40864079
}

0 commit comments

Comments
 (0)