google / google/xls

Formatter inserts newlines in empty `else` statements

Open
#1,259 1 comment 0 reactions 0 assignees View on GitHub
bug dslx dslx:fmt fmt:whitespace
Dominant language
C++
Stars
1.9k
Forks
283
Avg merge
2d 10h
Merged PRs (30d)
135

Description

Hi,

in the example below, if the condition label is long enough (`slightly_longer_condition`) and `else` statement is empty, then formatter decides to insert 2 new empty newlines, which seems to be a bug. Correct behavior is exhibited by the first example (`condition`).
```
proc Formatter {
config() { () }

init { () }

next(tok: token, state: ()) {
let condition = bool:true;
if condition { trace_fmt!("Hello, condition = {}", condition); } else { };
let slightly_longer_condition = bool:true;
if slightly_longer_condition {
trace_fmt!("Hello, condition = {}", slightly_longer_condition);
} else {

};
}
}
```
Formatter built from commit 1da08a2e3146a0708719a273119f24d56a8e2015

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.