Formatter: five cases where comments and doc comments are placed wrongly
維護者通常 1 天內回覆
已經有一個關聯 PR 被合併了。
- #9119 來自 @cknitt —— 已合併
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 35/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 停滯
- 技術堆疊
- ocaml
- 領域
- compilers
研究方向
Start with the formatter cases described in the issue and inspect parameters_should_hug in compiler/syntax/src/res_parsetree_viewer.ml for the first case. Reproduce each of the five examples and trace the comment handling and formatting paths involved. Done means all five format correctly and remain stable when formatted again, with case 4 preserving the AST; an open pull request is already linked.
由索引模型根據 Issue 內容生成。
描述
Found by a bug hunt over the 16 commits from eb087382 to cd641cbc.
All five are stable when formatted again. The fourth changes the AST, and the others change only the layout.
- A doc comment on a single hugged parameter is printed with a line break and no indent:
let f = (/** r */ {x, y}) => xprints aslet f = (/** r */followed by{x, y}) => xat column 0. The same happens for[a],(a, b)and().parameters_should_hugchecks the parameter'sattrsbut notpat.ppat_attributes, where the doc comment is stored. This input is accepted since #9055. - A trailing line comment after a parenthesized
switch/ifoperand moves into the block, followed by a blank line:
switch (x) // c1then{ | 1 => 2 | _ => 3 }prints asswitch x {, then// c1, a blank line and| 1 => 2. Without the parentheses (#9061) the comment stays with the operand. - A comment before a list tail spread moves after the dots:
list{1, /* c */ ...xs}prints aslist{1, .../* c */ xs}. Arrays keep it in place. - Doc comments are printed before an attribute that precedes them, which changes the attribute order in the AST:
type u = /** d1 */ @a /** d2 */ {x: int}prints/** d1 */,/** d2 */, then@a type u = {x: int}. - A file that contains only a line comment gets an extra trailing newline:
// c\nformats as// c\n\n.
Cases 2, 3 and 5 reproduce at b123b7c3. That revision rejects the inputs of 1 and 4.
🤖 Generated with Claude Code
- 主要語言
- OCaml
- 星號
- 7.5k
- 分支
- 484
- 平均合併
- 21 小時 9 分鐘
- 30 天內合併 PR
- 255
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
rescript-lang/rescript 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 74/100
rescript-lang/rescript#9135 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 74/100
rescript-lang/rescript#9132 ·
維護者通常 1 天內回覆
-
Printed type declarations drop @tag, @notUndefined and runtime annotations可能已有人在做 @cknitt 今天認領。 未關閉
難度 4/5 1-2 天 新手友好度 25/100
rescript-lang/rescript#9134 ·
維護者通常 1 天內回覆
-
難度 5/5 一週以上 新手友好度 35/100
rescript-lang/rescript#9130 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 4/5 1-2 天 新手友好度 55/100
rescript-lang/rescript#9122 ·
維護者通常 1 天內回覆
查看 rescript-lang/rescript 的全部 Issue
相似的 Issue
-
confirmed generated by fuzzer llvm:codegen miscompilation
難度 2/5 1-3 小時 新手友好度 75/100
llvm/llvm-project#237380 ·
維護者通常 1 天內回覆
-
area:observer area:trace-tape found-by:code-review kind:docs-drift
難度 2/5 1-3 小時 新手友好度 85/100
InauguralSystems/EigenScript#2212 ·
維護者通常 1 天內回覆
-
bug medium priority openmp tokenizer wrong result
難度 2/5 1-3 小時 新手友好度 82/100
維護者通常 1 天內回覆
-
import: a segment starting with a digit is refused, but the error says digits are allowed可能已有人在做 @sebastianbreguel 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 68/100
HigherOrderCO/Bend#1961 ·
-
bug pdd
難度 2/5 1 小時以內 新手友好度 60/100
objectionary/eo#9675 ·
維護者通常 1 天內回覆