Skip to content
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

[BUG] Weird auto-formatting for lines with a trailing comment #2561

Open
nmsmith opened this issue May 7, 2024 · 0 comments
Open

[BUG] Weird auto-formatting for lines with a trailing comment #2561

nmsmith opened this issue May 7, 2024 · 0 comments
Labels
bug Something isn't working Initiative: Format mojo-repo Tag all issues with this label

Comments

@nmsmith
Copy link
Contributor

nmsmith commented May 7, 2024

Bug description

The following program:

fn main():
    var a = Int(0)
    var b: Int
    b = a^  # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

is auto-formatted as:

fn main():
    var a = Int(0)
    var b: Int
    b = (
        a^
    )  # xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Whereas if the ^ sigil is removed, or if the initialization is done on the same line as the declaration (var b = a^), the auto-formatter doesn't intervene.

Ideally, in all cases, the formatter will just leave the code alone, because splitting it over multiple lines doesn't aid readability.

This issue isn't specific to the ^ sigil. It also occurs with lines like b = +a and b = a + 1.

System information

MacOS Ventura
Mojo nightly 2024.5.622 (d9dc4c21)
@nmsmith nmsmith added bug Something isn't working mojo-repo Tag all issues with this label labels May 7, 2024
@JoeLoser JoeLoser added the mojo-tooling Tag for all issues related to repl, lldb, lsp, vscode extension. label May 8, 2024
@ematejska ematejska removed the mojo-tooling Tag for all issues related to repl, lldb, lsp, vscode extension. label May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Initiative: Format mojo-repo Tag all issues with this label
Projects
None yet
Development

No branches or pull requests

4 participants