@@ -393,7 +393,7 @@ pub fn getErrorBundleFromStderr(
393393
394394 const src_loc = if (single_file_source ) | source | src_loc : {
395395 const source_index = offsets .positionToIndex (source , utf8_position , .@"utf-8" );
396- const source_line = offsets .lineSliceAtIndex (source , source_index );
396+ const source_loc = offsets .lineLocAtIndex (source , source_index );
397397
398398 var loc : offsets.Loc = .{ .start = source_index , .end = source_index };
399399
@@ -405,10 +405,11 @@ pub fn getErrorBundleFromStderr(
405405 .src_path = eb_src_path ,
406406 .line = utf8_position .line ,
407407 .column = utf8_position .character ,
408- .span_start = @intCast (loc .start ),
408+ // span_start <= span_main <= span_end <= source_loc.end
409+ .span_start = @intCast (@min (source_index , loc .start )),
409410 .span_main = @intCast (source_index ),
410- .span_end = @intCast (loc .end ),
411- .source_line = try error_bundle .addString (source_line ),
411+ .span_end = @intCast (@min ( @max ( source_index , loc .end ), source_loc . end ) ),
412+ .source_line = try error_bundle .addString (offsets . locToSlice ( source , source_loc ) ),
412413 });
413414 } else src_loc : {
414415 break :src_loc try error_bundle .addSourceLocation (.{
0 commit comments