<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - AlingConsecutiveAssignment aligns consecutive assignment across scopes"
   href="https://llvm.org/bugs/show_bug.cgi?id=25090">25090</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>AlingConsecutiveAssignment aligns consecutive assignment across scopes
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Formatter
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>gonzalobg88@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>djasper@google.com, klimek@google.com, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I have the following snippet that clang-format aligns incorrectly when using
the option AlignConsecutiveAssignment:

  auto time_steps                       = view::generate([]() mutable {
                      static num_t next = 0.;
                      auto r            = next;
                      next += 1. / 4. * pi;
                      return r;
                    })
                    | view::take(8);

The inner assignments inside the lambda are aligned correctly with respect to
each other, but the outer assignment (outside of the lambda) is aligned
incorrectly, since it has nothing to do with the assignments inside the lambda.

It would  be worth checking if similar error appears in other situations like
constructors:
  auto one_var    = 3; 
  auto my_var     = type {
          one_var = 4, 3, 2 };

or control statements:

  int one_var  = 3;  
  if ((one_var = 4)) { }

I guess that as a rule of thumb AlignConsecutiveAssignment should only align
consecutive assignments that happen exactly in the same scope. That should
probably fix all the problems since uniform initialization in constructors as
well as expressions inside control statements have all their own scope.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>