Page MenuHomePhabricator

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

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



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.

Diff Detail

Event Timeline

mprobst created this revision.Jan 20 2020, 3:23 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 20 2020, 3:23 AM
Eugene.Zelenko added a project: Restricted Project.
krasimir accepted this revision.Jan 20 2020, 7:50 AM
This revision is now accepted and ready to land.Jan 20 2020, 7:50 AM
This revision was automatically updated to reflect the committed changes.