You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix removing parentheses when using deducing assignement
The issue is caused by `emit(expression_list_node)` that skips parentheses
when node is inside initializer - that serves cases like:
```cpp
v : std::vector<int> = (1,2,3);
```
Where it generates:
```cpp
std::vector<int> v{1,2,3};
```
When `:=` is used in the following cases:
```cpp
d := (1 + 2) * (3 + 4) * (5 + 6);
```
It removes first parentheses and we end up with:
```cpp
auto d = {1 + 2 * (3 + 4) * ( 5 + 6)};
```
This change corrects this behaviour on the parsing side. After parsing
expression list it checks if the next lexeme is `Semicolon`. If it is it
means that we are on the initializer of the form:
```cpp
d1 := ((2 + 1) * (4 - 1) * (8 - 3));
d3 := (move d2);
v : std::vector<int> = ();
```
And we can suppres printing of parentheses - as there will be braces:
```cpp
auto d1 {(2 + 1) * (4 - 1) * (8 - 3)};
auto d3 {std::move(d2)};
std::vector<int> v {};
```
When next lexeme is not `Semicolon` it means that we are in initializer
of the form:
```cpp
d2 := (2 + 1) * (4 - 1) * (8 - 3);
d4 : _ = (1 + 2) * (3 + 4) * (5 + 6);
d5 : int = (1 + 2) * (3 + 4) * (5 + 6);
```
And we need to keep all the parentheses and it will be generates to:
```cpp
auto d2 {(2 + 1) * (4 - 1) * (8 - 3)};
auto d4 {(1 + 2) * (3 + 4) * (5 + 6)};
int d5 {(1 + 2) * (3 + 4) * (5 + 6)};
```
0 commit comments