Skip to content

Unstable formatting of comments #6976

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
cknitt opened this issue Aug 26, 2024 · 0 comments
Open

Unstable formatting of comments #6976

cknitt opened this issue Aug 26, 2024 · 0 comments
Milestone

Comments

@cknitt
Copy link
Member

cknitt commented Aug 26, 2024

Example adapted from jscomp/test/tramp_fib.res:

let rec fib = (n, k) =>
  switch n {
  | 0 | 1 => k(1)
  | _ =>
    Suspend(
      () =>
        fib(n - 1, (v0) =>
          fib(n - 2, (v1) =>
            k(v0 + v1)
            /* comment */
          )
        ),
    )
  }

Formatted:

let rec fib = (n, k) =>
  switch n {
  | 0 | 1 => k(1)
  | _ =>
    Suspend(
      () =>
        fib(n - 1, v0 =>
          fib(n - 2, v1 => k(v0 + v1))
/* comment */
        ),
    )
  }

Formatted again:

let rec fib = (n, k) =>
  switch n {
  | 0 | 1 => k(1)
  | _ =>
    Suspend(
      () =>
        fib(n - 1, v0 => fib(n - 2, v1 => k(v0 + v1))),
/* comment */
    )
  }

Formatted once more:

let rec fib = (n, k) =>
  switch n {
  | 0 | 1 => k(1)
  | _ =>
    Suspend(
      () =>
        fib(n - 1, v0 => fib(n - 2, v1 => k(v0 + v1))),
        /* comment */
    )
  }

After the third formatting, the output is now stable.

@cknitt cknitt added this to the v12 milestone Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant