Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: revert #1092
  • Loading branch information
JohelEGP authored and threeifbyair committed Nov 15, 2025
commit 6f16a23f9004b1bbe20a77bcef0db74c810faeb2
6 changes: 6 additions & 0 deletions regression-tests/pure2-bugfix-for-nested-lists.cpp2
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,9 @@ main: () = {
// Still parentheses (for now?)
assert((:std::vector = (17, 29)).size() == 2);
}

issue_1283: () = {
arr: std::array<std::string, 10> = ();
f: MyFunctor = ("Some initial value");
std::ranges::generate(arr, :() (f&$*)());
}
10 changes: 10 additions & 0 deletions regression-tests/test-results/pure2-bugfix-for-nested-lists.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public: explicit point();

auto main() -> int;

#line 29 "pure2-bugfix-for-nested-lists.cpp2"
auto issue_1283() -> void;

//=== Cpp2 function definitions =================================================

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

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

6 changes: 0 additions & 6 deletions source/parse.h
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,6 @@ struct expression_list_node
token const* open_paren = {};
token const* close_paren = {};
bool inside_initializer = false;
bool default_initializer = false;

struct term {
passing_style pass = {};
Expand Down Expand Up @@ -6514,7 +6513,6 @@ class parser
};
mutable std::vector<function_body_extent> function_body_extents;
mutable bool is_function_body_extents_sorted = false;
bool is_inside_call_expr = false;

public:
auto is_within_function_body(source_position p) const
Expand Down Expand Up @@ -6901,8 +6899,6 @@ class parser
expr_list->inside_initializer = false;
}
n->expression_list_is_fold_expression = expr_list->is_fold_expression();
expr_list->default_initializer =
is_inside_call_expr && std::empty(expr_list->expressions);

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

if (
term.expr_list
Expand Down
7 changes: 0 additions & 7 deletions source/to_cpp1.h
Original file line number Diff line number Diff line change
Expand Up @@ -4191,13 +4191,6 @@ class cppfront
!(n.inside_initializer && current_declarations.back()->initializer->position() != n.open_paren->position())
;

if (n.default_initializer) {
if (add_parens) {
printer.print_cpp2("{}", n.position());
}
return;
}

if (add_parens) {
printer.print_cpp2( *n.open_paren, n.position());
}
Expand Down