<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/58149>58149</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang-format nested object initializers violate BreakBeforeBraces: Attach
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
3geek14
</td>
</tr>
</table>
<pre>
In C#, I have an object initializer where one of the properties is defined again with an object initializer. When I use `BreakBeforeBraces: Attach`, I expect each opening curly brace to be at the end of the line, rather than making a new line. However, for the inner object initializer, clang-format is putting it on a new line.
`example.cs`:
var f = new MyObj {
Vector = {
X = 0,
Y = 0,
},
};
`clang-format.exe --style="{BasedOnStyle: LLVM, BreakBeforeBraces: Attach}" example.cs
var f = new MyObj {
Vector =
{
X = 0,
Y = 0,
},
};
I wasn't sure if the issue was that the open brace was immediately after the assignment, so I tried an array initializer as well, and clang-format gets that one correct:
int[] x = {
0,
1,
};
I expect it's just a failure to parse the inner object initializer in C#.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJylVE1v2zAM_TX2hYhhS46THHxIGgwr0KKHAd12lG3aVivLgSTnY79-lJOiSZtlAxYkjkVS5OPTo4q-OuT3Gu4CxgN2B_fQii2C0NAXL1g6kFo6KZT8hQZ2LRqEXtOvBtcibEy_QeMkWpAWKqylxgpEI6SGnXTt9TwRfG9RU6nBIgRZvDIoXldY9wZXRpRoA76EpXOibMl7RIX7jc-CZAOqqaVuoByMOkDht4DroSDYboSFunpDqAiRz2AErQyZCFEnXv12ARp3Y0AEX_sdbtH4SIIx7pRa04bP6H1MqYRuJhTZUUXqfDM451NKR-ycJw7idRAvT88sxr3oNgqj0vrG-PLcDfTZCgM1BHw9Zng8PBUvEMxW7wEAzwSHEPqYDx6AH6PZM3Zp_3nVHszWFxa_5qsPiM87jXCPMJlYd1BICQPGCMFKWKye9LejcQkPD8-PnqJbh-oLMzgj439ouGwVPrNyi5k_s_NvDN3DTlgdsJkDO9BsyKPqpLUDepcX3FGTXrQnrXq77DqspHBICha1w6PmhLWy0R1q5ym0PQnfGelHilRljDhcjCOl2aFSPlSQ4i9E2aA7FffjWvbGEGFXFCep1HQVTNewv6apj6wkf-XjNKiSOphZeBmso3mohVSeHprSjTA09bcGjN7H6ygKMU-yLF0kSZoswirn1YIvROikU5hfdKvROmLpcy4LW9krovmWHkO6R_LWuY23BewLfRu6vIYiKvuOFkpt3_4mdOP5GrQcz9jSy3SepIuwzRezjGfztJzXrCpLPuNzxissUj6fTYssqUMlClQ293wz5pU9pvBjNF2HMmcxY0kcU6-M80WUJRmf8nQqRJzUGd3OaYwd8Rh5HFFvmtDkI6RiaCw5lbTOvjuPUkLMj8cbisG1vcl5g_iapOFYOh-h_wamGc6s">