Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

Formatter: five cases where comments and doc comments are placed wrongly

Fermée
#9,107 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Une pull request liée a déjà été fusionnée.

  • #9119 par @cknitt — fusionnée

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
35/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
À l'abandon
Stack technique
ocaml
Domaine
compilers

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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.

  1. A doc comment on a single hugged parameter is printed with a line break and no indent:
    let f = (/** r */ {x, y}) => x prints as let f = (/** r */ followed by {x, y}) => x at column 0. The same happens for [a], (a, b) and (). parameters_should_hug checks the parameter's attrs but not pat.ppat_attributes, where the doc comment is stored. This input is accepted since #9055.
  2. A trailing line comment after a parenthesized switch/if operand moves into the block, followed by a blank line:
    switch (x) // c1 then { | 1 => 2 | _ => 3 } prints as switch x {, then // c1, a blank line and | 1 => 2. Without the parentheses (#9061) the comment stays with the operand.
  3. A comment before a list tail spread moves after the dots:
    list{1, /* c */ ...xs} prints as list{1, .../* c */ xs}. Arrays keep it in place.
  4. 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}.
  5. A file that contains only a line comment gets an extra trailing newline: // c\n formats 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

Langage dominant
OCaml
Étoiles
7.5k
Forks
484
Merge moyen
21 h 9 min
PR mergées (30 j)
255

Préparer son environnement

Ouvrir dans Codespaces

Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de rescript-lang/rescript

Toutes les issues de rescript-lang/rescript

Issues similaires

Plus d'issues Compilers

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.