Closed
Description
Describe the bug
Hello, first, let me thank you all for great work.
I was learning language from the test cases, and something caught my eye in this line
I'm not C++ expert but I believe
std::move(x) >> 1
doesn't make much sense in cpp1. It compiles, but I think move is lost to nowhere. (May be I am wrong and x is still marked as to be moved? But I think not)
To Reproduce
I have created this test:
dup: (a:_) -> _ = {
x := a;
return x + x;
}
inc: (a:_) -> _ = {
x := a;
return x + 1;
}
main: () -> int = {
obj := 42;
std::cout << dup(obj) << '\n';
std::cout << inc(obj);
}
which generates following cpp1:
[[nodiscard]] auto dup(auto const& a) -> auto{
auto x {a};
return x + std::move(x);
}
[[nodiscard]] auto inc(auto const& a) -> auto{
auto x {a};
return std::move(x) + 1;
}
I believe both of those cases loses information about move.
Additional context
Example uses int
, but I have checked with custom type (with operator+
) and it behaves the same.
Also its the same for other operators like *, >> etc.