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

Formatter drops comments in dict patterns, variant spread patterns and dict literal spreads

Abierto
#8,820 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 12/10/2026.

  • #8850 de @cknitt — abierto

Evaluación

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

Línea de trabajo

Start with res_comments_table.ml and res_printer.ml at the locations linked in the issue, then review the comment fixtures under tests/syntax_tests/data/printer/comments/. Reproduce with the provided cm.res command and add fixture cases for dict patterns and variant spread patterns. Done means formatting preserves every listed comment and the fixtures catch losses on the first print.

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

Descripción

Found by adversarial experiments on semantic analysts.

What is broken

The formatter deletes comments in these positions:

  • Dict pattern key: | dict{"a" /* k */: b} → | dict{"a": b}
  • Dict pattern value: | dict{"a": /* c */ a} → | dict{"a": a} (the record pattern {a: /* c */ a} keeps its comment)
  • Empty dict pattern: | dict{/* e */} → | dict{}
  • Variant spread pattern: | .../* c */ t → | ...t
  • Polymorphic variant type pattern: | #.../* c */ t → | #...t
  • Dict literal with a spread: an own-line comment before the first row after a spread is dropped (/* x */ on the same line is kept)

Reproduction

cm.res:

let f = d =>
  switch d {
  | dict{"a" /* k */: b} => b
  | dict{"a": /* c */ a} => a
  | dict{/* e */} => 0
  | _ => 1
  }
type t = A | B
type u = | ...t | C
let g = x =>
  switch x {
  | .../* c */ t => 0
  | #.../* c */ t => 0
  | C => 1
  }
let b = dict{
  ...base,
  // first
  "a": 1,
}
./_build/default/compiler/syntax/cli/res_cli.exe cm.res

Observed: every comment above is missing from the output. Expected: each comment is printed.

Where

No comment fixture covers dict patterns or variant spread patterns (tests/syntax_tests/data/printer/comments/). The roundtrip test compares the first formatting with the second, so a comment lost on the first print passes. The fix should add these cases to the comment fixtures.

Introduced by

The same output is produced at ece8b148, before the dict pattern and variant spread nodes existed. The current code comes from b081cd19c (#8749) and bffd18e7b (#8742).

Impact

Running the formatter silently deletes user comments.

Lenguaje dominante
OCaml
Estrellas
7.5k
Forks
484
Merge medio
18 h 19 min
PR fusionados (30 d)
116

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 Testing & QA

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.