[llvm-bugs] [Bug 40999] New: clang-format messes up indentation when using JavaScript private fields and methods

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Mar 7 14:21:32 PST 2019


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

            Bug ID: 40999
           Summary: clang-format messes up indentation when using
                    JavaScript private fields and methods
           Product: clang
           Version: 8.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Formatter
          Assignee: unassignedclangbugs at nondot.org
          Reporter: d at domenic.me
                CC: djasper at google.com, klimek at google.com,
                    llvm-bugs at lists.llvm.org

Input:

class Example {
  pub = 1;
  #priv = 2;

  static pub2 = "foo"
  static #priv2 = "bar";

  method() {
    this.#priv = 5;
  }

  static staticMethod() {

  }

  #privateMethod() {
    this.#privateMethod(); // infinite loop
  }

  static #staticPrivateMethod() {

  }
}



clang-format -i test.js

Output:

class Example {
  pub = 1;
#priv = 2;

  static pub2 = 'foo' static #priv2 = 'bar';

  method() {
    this.#priv = 5;
  }

  static staticMethod() {}

#privateMethod() {
  this.#privateMethod();  // infinite loop
}

static #staticPrivateMethod() {}
}


Expected output: something like

class Example {
  pub = 1;
  #priv = 2;

  static pub2 = 'foo';
  static #priv2 = 'bar';

  method() {
    this.#priv = 5;
  }

  static staticMethod() {}

  #privateMethod() {
    this.#privateMethod();  // infinite loop
  }

  static #staticPrivateMethod() {}
}

Private fields are a relatively new JavaScript feature, but we are hoping to
use them in Google Chrome:
https://chromium-review.googlesource.com/c/chromium/src/+/1496278

clang-format version 8.0.0 (trunk 346566)

-- 
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/20190307/e21416bc/attachment-0001.html>


More information about the llvm-bugs mailing list