Skip to content

Commit 6f16a23

Browse files
JohelEGPthreeifbyair
authored andcommitted
fix: revert #1092
1 parent 536bd43 commit 6f16a23

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
@@ -784,7 +784,6 @@ struct expression_list_node
784784
token const* open_paren = {};
785785
token const* close_paren = {};
786786
bool inside_initializer = false;
787-
bool default_initializer = false;
788787

789788
struct term {
790789
passing_style pass = {};
@@ -6514,7 +6513,6 @@ class parser
65146513
};
65156514
mutable std::vector<function_body_extent> function_body_extents;
65166515
mutable bool is_function_body_extents_sorted = false;
6517-
bool is_inside_call_expr = false;
65186516

65196517
public:
65206518
auto is_within_function_body(source_position p) const
@@ -6901,8 +6899,6 @@ class parser
69016899
expr_list->inside_initializer = false;
69026900
}
69036901
n->expression_list_is_fold_expression = expr_list->is_fold_expression();
6904-
expr_list->default_initializer =
6905-
is_inside_call_expr && std::empty(expr_list->expressions);
69066902

69076903
n->expr = std::move(expr_list);
69086904
return n;
@@ -7058,9 +7054,7 @@ class parser
70587054
// Next should be an expression-list followed by a ')'
70597055
// If not, then this wasn't a call expression so backtrack to
70607056
// the '(' which will be part of the next grammar production
7061-
is_inside_call_expr = true;
70627057
term.expr_list = expression_list(term.op, lexeme::RightParen, true);
7063-
is_inside_call_expr = false;
70647058

70657059
if (
70667060
term.expr_list

source/to_cpp1.h

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

4194-
if (n.default_initializer) {
4195-
if (add_parens) {
4196-
printer.print_cpp2("{}", n.position());
4197-
}
4198-
return;
4199-
}
4200-
42014194
if (add_parens) {
42024195
printer.print_cpp2( *n.open_paren, n.position());
42034196
}

0 commit comments

Comments
 (0)