Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Formatter moves a line comment in a switch/if/loop operand into the block

Abierto
#9,060 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@cknitt ya está trabajando en esto.

Desde el 27/10/2026.

  • #9061 de @cknitt — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
ocaml
Área
tooling

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.y and obj // c\n.x // d\n.y
  • arr[// c\n0], obj[// c\n"member"], obj["member"] // c\n{
  • obj // c\n->f
  • a // c\n+ b
  • for i in 0 // c\nto n {: the comment moves past to n and 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.

Lenguaje dominante
OCaml
Estrellas
7.5k
Forks
483
Merge medio
20 h 7 min
PR fusionados (30 d)
227

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de rescript-lang/rescript

Todos los issues de rescript-lang/rescript

Issues similares

Más issues de DevTools

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.