[llvm-bugs] [Bug 40499] New: Incorrect indentation of anonymous function in javascript

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jan 28 09:20:56 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=40499

            Bug ID: 40499
           Summary: Incorrect indentation of anonymous function in
                    javascript
           Product: clang
           Version: 7.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: mmalerba at google.com
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

I think this is a bug (though maybe it's done intentionally for reasons I
haven't thought of):

When formatting a file like this (`clang_format -style=Google file.js`):

```js
f(g(() => {
  console.log('hi');
}));          
```

It results in no change to the file, as I would expect. However when I run the
same command on this file:

```js
f('', g(() => {
  console.log('hi');
}));      
```

I wind up with this:

```js
f('', g(() => {
    console.log('hi');
  }));
```

This is particularly frustrating when writing Angular tests, because I often
have test blocks of this form:

```js
it('does stuff', fakeAsync(() => {
  expect(thing).toBe(otherThing);
}));
```

Unfortunately, due to this bug, the indentation winds up looking wonky.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190128/15a6f126/attachment-0001.html>


More information about the llvm-bugs mailing list