# Why does std.zon.parse.Diagnostics.fmt add a trailing newline?

**URL:** <https://ziggit.dev/t/why-does-std-zon-parse-diagnostics-fmt-add-a-trailing-newline/17806>\
**Category:** Help\
**Tags:** standard-library\
**Created:** [October 2, 2026, 11:23pm UTC](https://ziggit.dev/t/why-does-std-zon-parse-diagnostics-fmt-add-a-trailing-newline/17806 "2026-10-02T23:23:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pasta](https://ziggit.dev/user_avatar/ziggit.dev/pasta/32/6273_2.png) [@pasta](https://ziggit.dev/u/pasta)\
**Post date:** [October 2, 2026, 11:23pm UTC](https://ziggit.dev/t/why-does-std-zon-parse-diagnostics-fmt-add-a-trailing-newline/17806/1 "2026-10-02T23:23:13Z")

</div>

Currently using `diag.fmt("bad.zon")` will produce a string that always has a trailing newline, bubbling out to `diag.log("bad.zon")` having an extra newline.

```zig
error: bad.zon:1:3: error: expected expression, found 'EOF'

```

This comes from [here](https://codeberg.org/ziglang/zig/src/branch/master/lib/std/zon/parse.zig#L119).

Plausible there’s a good reason for this, but it seems pretty odd. Does anyone know if this should be considered a bug worth reporting?

---

<div class="post-metadata">

**Author:** ![MasonRemaley](https://ziggit.dev/user_avatar/ziggit.dev/masonremaley/32/4454_2.png) [@MasonRemaley](https://ziggit.dev/u/MasonRemaley)\
**Post date:** [October 2, 2026, 11:56pm UTC](https://ziggit.dev/t/why-does-std-zon-parse-diagnostics-fmt-add-a-trailing-newline/17806/2 "2026-10-02T23:56:08Z")

</div>

This is a bug, feel free to file an issue. I’ll assign myself and fix it when I get a chance.

The problem is that multiple errors may be reported, a newline needs to separate them but the final newline should be elided.

(Edited)

---

<div class="post-metadata">

**Author:** ![pasta](https://ziggit.dev/user_avatar/ziggit.dev/pasta/32/6273_2.png) [@pasta](https://ziggit.dev/u/pasta)\
**Post date:** [October 3, 2026, 11:19pm UTC](https://ziggit.dev/t/why-does-std-zon-parse-diagnostics-fmt-add-a-trailing-newline/17806/3 "2026-10-03T23:19:19Z")

</div>

Thanks! Took a mo to get that reported with Codeberg being unhappy this weekend, but [here](https://codeberg.org/ziglang/zig/issues/37071) it is.

I can have a go myself too if you don’t get to it, other than finding callsites in the stdlib that might be relying on the extra newline it seems fairly simple.

---

<div class="post-metadata">

**Author:** ![MasonRemaley](https://ziggit.dev/user_avatar/ziggit.dev/masonremaley/32/4454_2.png) [@MasonRemaley](https://ziggit.dev/u/MasonRemaley)\
**Post date:** [October 4, 2026, 4:03am UTC](https://ziggit.dev/t/why-does-std-zon-parse-diagnostics-fmt-add-a-trailing-newline/17806/4 "2026-10-04T04:03:36Z")

</div>

I likely won’t get to it until next week, if you want to fix it go for it and feel free to request a review from me in the PR!

The main pain point will just be updating the tests, but I intentionally keep the test formatting very uniform to make find and replace possible.
