Skip to content

[BUG] inout parameter without non-const use of x works #230

Closed
@filipsajdak

Description

@filipsajdak

In section 1.3.2 inout parameters of https://github.com/hsutter/708/blob/main/708.pdf you specify that

If the function is nonvirtual, at least one path must contain a non-const use of x (else the parameter should be in).

In the current implementation of cppfront the following code compiles:

f2: (inout x) -> _ = {
    return x * 2;
}

main: () -> int = {
    x := 21;
    std::cout << f2(x) << std::endl;
    x = 0; // workaround for another bug
}

And generate output:

42

Expectations

cppfront should end with an error informing to use in argument passing instead of inout.

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