HomePhabricator

clang-format: [JS] do not collapse - - to --.

Authored by mprobst on Mar 29 2021, 4:12 AM.

Description

clang-format: [JS] do not collapse - - to --.

In JavaScript, - -1; is legal syntax, the language allows unary minus.
However the two tokens must not collapse together: --1 is prefix
decrement, i.e. different syntax.

Before:

  • -1; ==> --1;

After:

  • -1; ==> - -1;

This change makes no attempt to format this "nicely", given by all
likelihood this represents a programming mistake by the user, or odd
generated code.

The check is not guarded by language: this appears to be a problem in
Java as well, and will also be beneficial when formatting syntactically
incorrect C++ (e.g. during editing).

Differential Revision: https://reviews.llvm.org/D99495

Details

Committed
mprobstMar 30 2021, 5:31 AM
Differential Revision
D99495: clang-format: [JS] do not collapse - - to --.
Parents
rG69473d68b501: [gn build] Port c51e91e04681
Branches
Unknown
Tags
Unknown