reasonml / reasonml/reason

refmt comment reordering

Open
#920 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

KIND: BUG Printer
Dominant language
OCaml
Stars
10.3k
Forks
438
PR merge metrics
No merged PRs in 30d

Description

Looks like when we print multiple comments next to each other we are flipping the order.

In my case i'm working on an existing file and commenting out code until i'm ready to use it which means i sometimes have two comments directly next to each other but after a format the order gets flipped (which in my case messes up the meaning of the code).

Code:

switch "" {
  | a => a
  /*
  | 1 => b *//*
  | 2 => c */
};

Prints as:

switch "" {
| a => a /*
  | 2 => c */ /*
  | 1 => b */
};

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the example with refmt and inspect the formatter path that handles adjacent block comments. The change is complete when formatting preserves the original order of the two comments; add regression coverage using the provided switch example if the existing test structure is found.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.