Issue 58149
Summary clang-format nested object initializers violate BreakBeforeBraces: Attach
Labels new issue
Assignees
Reporter 3geek14
    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#.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to