Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] std::move for last-use makes it impossible to call function with inout parameter. #288

Closed
leejy12 opened this issue Mar 22, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@leejy12
Copy link

leejy12 commented Mar 22, 2023

The following Cpp2 code

foo: (inout x: i32) = {
    x = x + 1;
} 

main: () -> i32 = {
    a := 42;
    foo(a);
}

is compiled to (skipping boilerplate)

auto foo(cpp2::i32& x) -> void{
    x = x + 1;
}

[[nodiscard]] auto main() -> cpp2::i32{
    auto a {42}; 
    foo(std::move(a));
}

which fails to compile because cpp2::i32& x can't bind to std::move(a).

@leejy12 leejy12 added the bug Something isn't working label Mar 22, 2023
@filipsajdak
Copy link
Contributor

Duplicate of #231

@leejy12
Copy link
Author

leejy12 commented Mar 22, 2023

@filipsajdak Thanks! I will close this issue.

@leejy12 leejy12 closed this as completed Mar 22, 2023
@hsutter
Copy link
Owner

hsutter commented Mar 22, 2023

Ack: Thanks for the ping, I do want to fix this,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants