main: () = {
(copy a: std::string, copy b: std::string) {
a = "Hello, ";
b = "World! ";
std::cout << a << b;
}
}
Expected result - what you expected to happen
I would expect one of these to happen:
a. cppfront errors out and tells me that I need to initialize the parameters (if thats the intention)
b. They are lowered wrapped in the deferred_init class and the usual lifetime initialization semantics apply
c. they are lowered as is, just with the extra ;
Actual result/error
outputs the following c++ code (redundant parts omitted):
auto main() -> int{
{
std::string a // <- whoops!
std::string b // <- whoops!
{
a = "Hello, ";
b = "World! ";
std::cout << cpp2::move(a) << cpp2::move(b);
}
}
}
Additional context
I call this "Code block with parameters", but I don't know if there's a better name for them. I checked the documentation and they are referenced as "more RAII locally-scoped variables" and "local and immediate (aka 'let' in other languages)" which doesn't roll off the tongue too well 😛
Describe the bug Title.
To Reproduce Steps to reproduce the behavior:
deferred_init
class and the usual lifetime initialization semantics apply c. they are lowered as is, just with the extra;
Additional context I call this "Code block with parameters", but I don't know if there's a better name for them. I checked the documentation and they are referenced as "more RAII locally-scoped variables" and "local and immediate (aka 'let' in other languages)" which doesn't roll off the tongue too well 😛