Formatter: five cases where comments and doc comments are placed wrongly
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.
- A doc comment on a single hugged parameter is printed with a line break and no indent:
let f = (/** r */ {x, y}) => xprints aslet f = (/** r */followed by{x, y}) => xat column 0. The same happens for[a],(a, b)and().parameters_should_hugchecks the parameter'sattrsbut notpat.ppat_attributes, where the doc comment is stored. This input is accepted since #9055. - A trailing line comment after a parenthesized
switch/ifoperand moves into the block, followed by a blank line:
switch (x) // c1then{ | 1 => 2 | _ => 3 }prints asswitch x {, then// c1, a blank line and| 1 => 2. Without the parentheses (#9061) the comment stays with the operand. - A comment before a list tail spread moves after the dots:
list{1, /* c */ ...xs}prints aslist{1, .../* c */ xs}. Arrays keep it in place. - 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}. - A file that contains only a line comment gets an extra trailing newline:
// c\nformats 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
Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de rescript-lang/rescript
-
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
rescript-lang/rescript#9135 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
rescript-lang/rescript#9132 ·
Les mainteneurs répondent en général sous 1 jour
-
Printed type declarations drop @tag, @notUndefined and runtime annotationsPeut-être pris @cknitt l’a pris aujourd’hui. Ouverte
Difficulté 4/5 1-2 jours Accessibilité débutants 25/100
rescript-lang/rescript#9134 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 35/100
rescript-lang/rescript#9130 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 4/5 1-2 jours Accessibilité débutants 55/100
rescript-lang/rescript#9122 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de rescript-lang/rescript
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Les mainteneurs répondent en général sous 4 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
CanadaHonk/porffor#426 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 77/100
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
compiler-rt:asan llvm:transforms
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
llvm/llvm-project#236682 ·
Les mainteneurs répondent en général sous 1 jour