You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 91e8846
Browse filesBrowse the repository at this point in the historyBrowse files
Keep line comments in operands followed by a block
Why:
A line comment inside the operand of switch, try, if, while or a loop
was printed as a line suffix in a flat group, so it moved behind the
opening brace, and the next format attached it to the block.
The operand now breaks the groups around such a comment, and a comment
trailing the whole operand goes into parentheses with it, as if conditions
already did.
Format modified (line comment in a switch operand):
Example:
let x = switch [
a, // c
b,
] {
| _ => 1
}
Before (rescript):
let x = switch [a, b] { // c
| _ => 1
}
After (rescript):
let x = switch [
a, // c
b,
] {
| _ => 1
}
Review: Why not make every same-line line comment break its group? That changes code that formats stably today, such as foo(v :> b) // comment, which would split over three lines; the drift only happens before a block.
Area: printer tests
Output: unchanged
Formatting: changed operands of switch, try, if, while and loops that
contain a line comment; 80 operand/comment combinations format
idempotently (48 did not before), and 330 spread contexts format as before
apart from those
Formats: none
PPX: unchanged
Editor: unchanged
Tests: +tests/syntax_tests/data/printer/comments/operandBeforeBlock.res
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EUpL6dKCiSwAeriDGRHqNr
Claude-Session: https://claude.ai/code/session_01Kr4cjoUi2f5VpMvE6wT9bo
Signed-off-by: Christoph Knittel <ck@cca.io>
- Fix the formatter moving a line comment in the operand of `switch`, `try`, `if`, `while` or a loop into the block that follows, which changed it again on every format.
0 commit comments