cppfront icon indicating copy to clipboard operation
cppfront copied to clipboard

[BUG] parens are not preserved when used for calculating argument value

Open filipsajdak opened this issue 3 years ago • 0 comments
trafficstars

Parens disappear when used inside function call to calculate value of argument.

Given cpp2 code:

f: (x:_) = {}

main: () -> int = {
    i := 2;
    f((i+(i+1)*2)/2);
}

When compiled with cppfront we get (I am skipping the boilerplate)

[[nodiscard]] auto main() -> int{
    auto i { 2 }; 
    f( i + i + 1 * 2 / 2);
}

all parens inside the function call are gone. (i+(i+1)*2)/2 is not equal i + i + 1 * 2 / 2.

The expectation is that all parens used to calculate arguments will last cppfront compilation.

filipsajdak avatar Oct 10 '22 23:10 filipsajdak