Describe the bug
This is a minor formatting bug when lowering to C++.
Assigning a function expression to a constexpr variable causes the lowered C++ function's compound statement / block to be formatted incorrectly. The emission of the newlines appear to be delayed.
To Reproduce
Run cppfront on this code:
main: () = {
add_v1: = :(a, b) -> _ = {
a += 1;
b += 2;
return a + b;
};
// Note the difference here
// v
add_v2: == :(a, b) -> _ = {
a += 1;
b += 2;
return a + b;
};
}
It lowers to:
auto main() -> int{
auto add_v1 {[](auto const& a, auto const& b) mutable -> auto{
a += 1;
b += 2;
return a + b;
}};
auto constexpr add_v2 = [](auto const& a, auto const& b) mutable -> auto{a += 1;b += 2;return a + b; };
}
(EDIT - Please ignore the += for the const-ref params, I'm just keeping the syntax short.)
Repro on Godbolt
Describe the bug This is a minor formatting bug when lowering to C++. Assigning a function expression to a
constexpr
variable causes the lowered C++ function's compound statement / block to be formatted incorrectly. The emission of the newlines appear to be delayed.To Reproduce Run cppfront on this code:
It lowers to:
(EDIT - Please ignore the
+=
for the const-ref params, I'm just keeping the syntax short.) Repro on Godbolt