Skip to content

Formatter appends comma to empty tuple that contains a comment #4676

Description

@achowd32

Describe the bug
This is an edge case where the formatter messes up an empty tuple that contains a comment.

To Reproduce
Consider the following code:

fn tup() -> () {
   (
       // this is an empty tuple
   )
}

Running this through the formatter generates

fn tup() -> () {
   (
       , // this is an empty tuple
   )
}

Notice the addition of the stray comma, which the interpreter is not able to parse.
Expected behavior
The comma should not be added.

Additional context
I think this is a fairly simple bug, I would be interested in resolving this is maintainers agree it is an issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions