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

zig fmt places code at wrong indentation with comment preceding payload #21102

Open
nektro opened this issue Aug 17, 2024 · 0 comments · May be fixed by #21403
Open

zig fmt places code at wrong indentation with comment preceding payload #21102

nektro opened this issue Aug 17, 2024 · 0 comments · May be fixed by #21403
Labels
bug Observed behavior contradicts documented or intended behavior zig fmt
Milestone

Comments

@nektro
Copy link
Contributor

nektro commented Aug 17, 2024

Zig Version

0.13.0

Steps to Reproduce and Observed Behavior

catch places comment at wrong indentation

comptime {
    _ = foo() catch
    //
        bar();
}

else places comment and payload at wrong indentation

comptime {
    _ = if (foo) bar() else
    //
    qux();
}

orelse canonicalizes as expected

comptime {
    _ = foo() orelse
        //
        qux();
}

Expected Behavior

a comment following catch, else, orelse should place the comment and payload indented from the top of the expression

@nektro nektro added the bug Observed behavior contradicts documented or intended behavior label Aug 17, 2024
@Vexu Vexu added the zig fmt label Aug 17, 2024
@Vexu Vexu added this to the 0.15.0 milestone Aug 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior zig fmt
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants