Skip to content

zig fmt: preserve formatting for function parameters with doc comments#25274

Open
jedisct1 wants to merge 2 commits intoziglang:masterfrom
jedisct1:zigfmtfix
Open

zig fmt: preserve formatting for function parameters with doc comments#25274
jedisct1 wants to merge 2 commits intoziglang:masterfrom
jedisct1:zigfmtfix

Conversation

@jedisct1
Copy link
Contributor

Previously, zig fmt would collapse function declarations with doc comments onto a single line, creating invalid syntax like:

    fn foo(/// comment
    _: void) void {}

Now we check for doc comments between parentheses and prevent the single-line formatting when doc comments are present, ensuring proper line separation and adding trailing comma when needed.

Fixes #18088
Fixes #25267

Previously, zig fmt would collapse function declarations with doc comments
onto a single line, creating invalid syntax like:

```zig
    fn foo(/// comment
    _: void) void {}
```

Now we check for doc comments between parentheses and prevent the
single-line formatting when doc comments are present, ensuring proper
line separation and adding trailing comma when needed.

Fixes ziglang#18088
@andrewrk andrewrk self-requested a review September 19, 2025 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant