Skip to content

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

Closed
@leejy12

Description

@leejy12

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions