zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit fc69529dab66254d353975844034dab545a7335b (tree)
parent 4f952c7e0e36dab15f9359f55eb8714f8fe92bcf
Author: Ryan Liptak <squeek502@hotmail.com>
Date:   Mon,  4 Sep 2023 01:33:53 -0700

ErrorBundle.addOtherSourceLocation: Fix source_line ending up as garbage when source_line is 0

The zero value needs special handling since it means 'no source line' and should be preserved through the copy.

Diffstat:
Mlib/std/zig/ErrorBundle.zig | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/lib/std/zig/ErrorBundle.zig b/lib/std/zig/ErrorBundle.zig @@ -474,7 +474,10 @@ pub const Wip = struct { .span_start = other_sl.span_start, .span_main = other_sl.span_main, .span_end = other_sl.span_end, - .source_line = try wip.addString(other.nullTerminatedString(other_sl.source_line)), + .source_line = if (other_sl.source_line != 0) + try wip.addString(other.nullTerminatedString(other_sl.source_line)) + else + 0, .reference_trace_len = other_sl.reference_trace_len, });