Formatter moves a line comment in a switch/if/loop operand into the block
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- ocaml
- Lĩnh vực
- tooling
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- OCaml
- Star
- 7.5k
- Fork
- 483
- Merge trung bình
- 20 giờ 50 phút
- Pull request đã merge (30 ngày)
- 230
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của rescript-lang/rescript
-
Create interface drops attributes in front of type declarationsCó thể đã có người làm @cknitt đã nhận hôm nay. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 58/100
rescript-lang/rescript#9095 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Dev dependencies interactingCó thể đã có người làm @CarlOlson đã nhận 1 ngày trước. Đang mở
Độ khó 4/5 1-2 ngày Mức phù hợp với người mới 25/100
rescript-lang/rescript#9089 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
rescript-lang/rescript#9074 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
No completion for extensible variant constructorsCó thể đã có người làm @cknitt đã nhận 1 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
rescript-lang/rescript#9073 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Hover and completion on an applied functor show the functor body's typesCó thể đã có người làm @cknitt đã nhận 1 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
rescript-lang/rescript#9072 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của rescript-lang/rescript
Issue tương tự
-
GitLab: a merge request closed without merging keeps the Git toolbar on View MR instead of Create MRĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
noontide-co/mainbranch#1256 · 1 bình luận ·
-
ready-for-agent tooling
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
KRoperUK/smeg-plus-patches#249 ·
Maintainer thường phản hồi trong vòng 1 ngày