Skip to content

doc comments on function parameters without a trailing comma causes invalid code after formatting #18088

@xdBronch

Description

@xdBronch

Zig Version

0.12.0-dev.1680+be6f76655

Steps to Reproduce and Observed Behavior

// fmt.zig
fn foo(
    /// uh oh no comma
    _: void
) void {}
$ zig fmt fmt.zig
fmt.zig
$ cat fmt.zig
fn foo(/// uh oh no comma
_: void) void {}
$ zig fmt fmt.zig
fmt.zig:1:8: error: same line documentation comment
fn foo(/// uh oh no comma
       ^~~~~~~~~~~~~~~~~~

Expected Behavior

zig fmt should keep the doc comment on a separate line or issue an error immediately rather than generating invalid code insert a trailing comma to keep the lines separate

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorzig fmt

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions