Description
Cpp1 error when trying to return object (by value?) from local variable
Code example
S : type = {
public x: int = 42;
}
baz: () -> _ = {
return S(); //ok cpp1: return S();
}
foo: () -> _ = {
//foo: () -> move _ = { //same behavior
s: S = ();
return s; //cpp1 error: see below
}
main: () = {
std::cout << baz().x;
std::cout << foo().x;
}
Actual result - cpp1 error
error: call to deleted constructor of 'typename std::remove_reference<S &>::type' (aka 'S')
return std::move(s);
note: 'S' has been explicitly marked deleted here
public: S(S const&) = delete;
Additional info
it is possible to return just constructed object like in baz()
Probably this is desired, but I dont see much difference why local cannot be returned here, and constructed object can.
Another note, it is working if type declared with @struct meta