Skip to content

Commit 1a05b5e

Browse files
committed
Fix multi return values handling
1 parent b1754db commit 1a05b5e

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

source/cppfront.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,15 +1086,12 @@ class cppfront
10861086
}
10871087

10881088
in_definite_init = is_definite_initialization(n.identifier);
1089-
if (in_synthesized_multi_return) {
1090-
printer.print_cpp2(".value()", n.position());
1091-
}
1092-
else if (!in_definite_init && !in_parameter_list) {
1089+
if (!in_definite_init && !in_parameter_list) {
10931090
if (auto decl = sema.get_declaration_of(*n.identifier);
10941091
is_local_name &&
10951092
decl &&
10961093
// note pointer equality: if we're not in the actual declaration of n.identifier
1097-
decl->identifier != n.identifier &&
1094+
(in_synthesized_multi_return || decl->identifier != n.identifier) &&
10981095
// and this variable was uninitialized
10991096
!decl->initializer &&
11001097
// and it's either a non-parameter or an out parameter
@@ -1104,6 +1101,9 @@ class cppfront
11041101
printer.print_cpp2(".value()", n.position());
11051102
}
11061103
}
1104+
else if (in_synthesized_multi_return) {
1105+
printer.print_cpp2(".value()", n.position());
1106+
}
11071107

11081108
if (add_std_move || add_std_forward) {
11091109
printer.print_cpp2(")", n.position());

source/sema.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,9 @@ class sema
250250
{
251251
auto const& decl = std::get<symbol::active::declaration>(i->sym);
252252

253-
// Don't look beyond the current function
253+
// Don't look beyond the current function but check if it is not a lambda
254254
assert(decl.declaration);
255-
if (decl.declaration->type.index() == declaration_node::function) {
255+
if (decl.declaration->identifier && decl.declaration->type.index() == declaration_node::function) {
256256
return nullptr;
257257
}
258258

0 commit comments

Comments
 (0)