HomePhabricator

clang-format: [JS] fix `??` opreator wrapping.

Authored by mprobst on Jan 20 2020, 3:19 AM.

Description

clang-format: [JS] fix ?? opreator wrapping.

Summary:
clang-format currently treats the nullish coalescing operator ?? like
the ternary operator. That causes multiple nullish terms to be each
indented relative to the last ??, as they would in a ternary.

The ?? operator is often used in chains though, and as such more
similar to other binary operators, such as ||. So to fix the indent,
set its token type to ||, so it inherits the same treatment.

This opens up the question of operator precedence. However, ?? is
required to be parenthesized when mixed with || and &&, so this is
not a problem that can come up in syntactically legal code.

Reviewers: krasimir

Subscribers: cfe-commits

Tags: #clang

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

Details

Committed
mprobstJan 20 2020, 8:07 AM
Differential Revision
D73026: clang-format: [JS] fix `??` opreator wrapping.
Parents
rG3de9a5db629a: [clangd] Avoid redundant testcases in rename unittest, NFC.
Branches
Unknown
Tags
Unknown