| ... | ... | @@ -572,6 +572,16 @@ pub const AllErrors = struct { |
| 572 | 572 | while (item_i < items_len) : (item_i += 1) { |
| 573 | 573 | const item = file.zir.extraData(Zir.Inst.CompileErrors.Item, extra_index); |
| 574 | 574 | extra_index = item.end; |
| 575 | const err_byte_offset = blk: { |
| 576 | const token_starts = file.tree.tokens.items(.start); |
| 577 | if (item.data.node != 0) { |
| 578 | const main_tokens = file.tree.nodes.items(.main_token); |
| 579 | const main_token = main_tokens[item.data.node]; |
| 580 | break :blk token_starts[main_token]; |
| 581 | } |
| 582 | break :blk token_starts[item.data.token] + item.data.byte_offset; |
| 583 | }; |
| 584 | const err_loc = std.zig.findLineColumn(file.source, err_byte_offset); |
| 575 | 585 | |
| 576 | 586 | var notes: []Message = &[0]Message{}; |
| 577 | 587 | if (item.data.notes != 0) { |
| ... | ... | @@ -600,33 +610,22 @@ pub const AllErrors = struct { |
| 600 | 610 | .line = @intCast(u32, loc.line), |
| 601 | 611 | .column = @intCast(u32, loc.column), |
| 602 | 612 | .notes = &.{}, // TODO rework this function to be recursive |
| 603 | | .source_line = try arena.dupe(u8, loc.source_line), |
| 613 | .source_line = if (loc.eql(err_loc)) null else try arena.dupe(u8, loc.source_line), |
| 604 | 614 | }, |
| 605 | 615 | }; |
| 606 | 616 | } |
| 607 | 617 | } |
| 608 | 618 | |
| 609 | 619 | const msg = file.zir.nullTerminatedString(item.data.msg); |
| 610 | | const byte_offset = blk: { |
| 611 | | const token_starts = file.tree.tokens.items(.start); |
| 612 | | if (item.data.node != 0) { |
| 613 | | const main_tokens = file.tree.nodes.items(.main_token); |
| 614 | | const main_token = main_tokens[item.data.node]; |
| 615 | | break :blk token_starts[main_token]; |
| 616 | | } |
| 617 | | break :blk token_starts[item.data.token] + item.data.byte_offset; |
| 618 | | }; |
| 619 | | const loc = std.zig.findLineColumn(file.source, byte_offset); |
| 620 | | |
| 621 | 620 | try errors.append(.{ |
| 622 | 621 | .src = .{ |
| 623 | 622 | .src_path = try file.fullPath(arena), |
| 624 | 623 | .msg = try arena.dupe(u8, msg), |
| 625 | | .byte_offset = byte_offset, |
| 626 | | .line = @intCast(u32, loc.line), |
| 627 | | .column = @intCast(u32, loc.column), |
| 624 | .byte_offset = err_byte_offset, |
| 625 | .line = @intCast(u32, err_loc.line), |
| 626 | .column = @intCast(u32, err_loc.column), |
| 628 | 627 | .notes = notes, |
| 629 | | .source_line = try arena.dupe(u8, loc.source_line), |
| 628 | .source_line = try arena.dupe(u8, err_loc.source_line), |
| 630 | 629 | }, |
| 631 | 630 | }); |
| 632 | 631 | } |