Skip to content

Misplaced comment in "else if" #3011

Open
@Smaug123

Description

@Smaug123

Issue created from fantomas-online

Code

let foo =
    if bar then
        a <- 1
    else
    // whatnot
    if baz then
        quux <- 3

Result

let foo =
    if bar then
        a <- 1
    else if
        // whatnot
        baz
    then
        quux <- 3

Problem description

The comment has been moved with respect to the if statement. Expected instead was:

let foo =
    if bar then
        a <- 1
    else
        // whatnot
        if baz then
            quux <- 3

(or, in my own codebase with ExperimentalKeepIndentInBranch, I expected no change to the formatting).

Extra information

  • The formatted result breaks my code.
  • The formatted result gives compiler warnings.
  • I or my company would be willing to help fix this.
  • I would like a release if this problem is solved.

Options

Fantomas main branch at 2023-12-06T16:47:58Z - 0f8ee23

Default Fantomas configuration

Did you know that you can ignore files when formatting by using a .fantomasignore file?
PS: It's unlikely that someone else will solve your specific issue, as it's something that you have a personal stake in.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions