Formatter moves a line comment in a switch/if/loop operand into the block
維護者通常 1 天內回覆
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 35/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 停滯
- 技術堆疊
- ocaml
- 領域
- tooling
研究方向
The issue describes the formatter’s line suffix handling and gives operand examples, but names no source files or tests. Start by locating the printer logic that queues trailing line comments and the formatter tests for switch, if, loop, and try operands. Add cases that verify comments stay in the operand across repeated formatting; done means formatting is idempotent for the examples. Pull request #9061 is already open.
由索引模型根據 Issue 內容生成。
描述
A line comment inside the operand of switch, if, while, for, for..of, for await..of or try moves when formatting: first after the {, then on the next run into the block. Formatting is not idempotent.
switch obj // c
.x {
| _ => ()
}
First run:
switch obj.x { // c
| _ => ()
}
Second run, the comment is now in the block:
switch obj.x {
// c
| _ => ()
}
The same happens with if, while, for..of, for await..of, try (where the comment moves past catch) and with these operands:
obj // c\n.x.yandobj // c\n.x // d\n.yarr[// c\n0],obj[// c\n"member"],obj["member"] // c\n{obj // c\n->fa // c\n+ bfor i in 0 // c\nto n {: the comment moves pastto nand into the loop body
switch f(// c\nx) { is fine, because the arguments group breaks after the comment.
Expected: the comment stays in the operand, for example
switch (
obj.x // c
) {
| _ => ()
}
Cause: the printer queues a trailing line comment as a line suffix and prints it at the next line break of a breaking group. The field access, object get, pipe or binary expression is printed flat with no line break after the comment, so the first break is the one after the block's {.
Found while reviewing #8906, which is about a related case, but this bug is already on master.
- 主要語言
- OCaml
- 星號
- 7.5k
- 分支
- 483
- 平均合併
- 20 小時 7 分鐘
- 30 天內合併 PR
- 227
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
rescript-lang/rescript 的其他 Issue
-
難度 4/5 3-5 天 新手友好度 57/100
rescript-lang/rescript#9063 ·
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 25/100
rescript-lang/rescript#9058 · 2 則留言 ·
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 12/100
rescript-lang/rescript#9044 · 1 則留言 · 3 個 reaction ·
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 35/100
rescript-lang/rescript#9006 · 1 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
-
Have formatter insert newlines around multi-line expressions可能已有人在做 @rolandpeelen 於 5 天前認領。 未關閉
難度 4/5 3-5 天 新手友好度 25/100
rescript-lang/rescript#8960 ·
維護者通常 1 天內回覆
查看 rescript-lang/rescript 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 77/100
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 65/100
codespell-project/codespell#4060 ·
維護者通常 1 天內回覆
-
design-review mac P2 ux
難度 2/5 1-3 小時 新手友好度 84/100
tosunlab/hisarapp-core#422 ·
-
bug
難度 2/5 1-3 小時 新手友好度 76/100
awslabs/aidlc-workflows#3209 · 1 則留言 ·
維護者通常 1 天內回覆
-
Installer never refreshes ledger version stamp on content-identical upgrades (check nags forever)未關閉
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆