@@ -412,18 +412,19 @@ pub fn getErrorBundleFromStderr(
412412
413413 const src_loc = if (maybe_source ) | source | src_loc : {
414414 const source_index = offsets .positionToIndex (source , utf8_position , .@"utf-8" );
415- const source_line = offsets .lineSliceAtIndex (source , source_index );
415+ const source_loc = offsets .lineLocAtIndex (source , source_index );
416416
417417 const loc = offsets .tokenIndexToLoc (source , source_index );
418418
419419 break :src_loc try error_bundle .addSourceLocation (.{
420420 .src_path = eb_src_path ,
421421 .line = utf8_position .line ,
422422 .column = utf8_position .character ,
423- .span_start = @intCast (loc .start ),
423+ // span_start <= span_main <= span_end <= source_loc.end
424+ .span_start = @intCast (@min (source_index , loc .start )),
424425 .span_main = @intCast (source_index ),
425- .span_end = @intCast (loc .end ),
426- .source_line = try error_bundle .addString (source_line ),
426+ .span_end = @intCast (@min ( @max ( source_index , loc .end ), source_loc . end ) ),
427+ .source_line = try error_bundle .addString (offsets . locToSlice ( source , source_loc ) ),
427428 });
428429 } else src_loc : {
429430 break :src_loc try error_bundle .addSourceLocation (.{
0 commit comments