Formatter moves a line comment in a switch/if/loop operand into the block
Maintainer antworten meist innerhalb von 1 Tag
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 35/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Veraltet
- Tech-Stack
- ocaml
- Bereich
- tooling
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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.
- Vorherrschende Sprache
- OCaml
- Sterne
- 7.5k
- Forks
- 484
- Ø Merge
- 20 Std. 43 Min.
- Gemergte PRs (30 T.)
- 263
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus rescript-lang/rescript
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
rescript-lang/rescript#9139 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
rescript-lang/rescript#9151 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Printed @as names of fields and constructors turn non-ASCII letters into other charactersEvtl. vergeben @cknitt hat das heute übernommen. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 25/100
rescript-lang/rescript#9142 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
rescript-lang/rescript#9130 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 4/5 1-2 Tage Anfängerfreundlichkeit 55/100
rescript-lang/rescript#9122 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in rescript-lang/rescript
Ähnliche Issues
-
namespace operations
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 65/100
EclipseFdn/open-vsx.org#15057 ·
Maintainer antworten meist innerhalb von 1 Tag
-
docs(prompts): IF BLOCKED workflow-scope branch says to comment on the issue on jira/local trackersOffenagent-butler-finding bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 77/100
jordansmall/spindrift#6238 ·
Maintainer antworten meist innerhalb von 1 Tag
-
build
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
MetricsHub/metricshub-community#1472 ·
Maintainer antworten meist innerhalb von 1 Tag
-
curriculum documentation quality
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
githubnext/gh-aw-workshop#5184 ·
Maintainer antworten meist innerhalb von 1 Tag
-
chore: package-lock.json drifted — npm ci fails on @posthog/core 1.61.2 vs 1.62.0 (cold install)Evtl. vergeben @spudly hat das heute übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
Maintainer antworten meist innerhalb von 1 Tag