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

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.

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

This comes from here.

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?

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)

Thanks! Took a mo to get that reported with Codeberg being unhappy this weekend, but here 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.

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.