aboutsummaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-07-16 12:22:53 +0300
committerGitHub <noreply@github.com>2022-07-16 12:22:53 +0300
commitb2486fbc5e83cca2ce31a6a16b2ad4ff8df170df (patch)
treebd96fb988a0bed8307cdafcbe6eecf1ac8bcfc93 /src/main.zig
parentda94227f783ec3c92859c4713b80a668f1183f96 (diff)
parentcf207df5926c2f303ad92069e44bec51bfa44148 (diff)
downloadzig-b2486fbc5e83cca2ce31a6a16b2ad4ff8df170df.tar.gz
zig-b2486fbc5e83cca2ce31a6a16b2ad4ff8df170df.zip
Merge pull request #12121 from Vexu/span
Stage2 point to error location using spans
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/main.zig b/src/main.zig
index 236bc498b3..823cbf8757 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -4387,7 +4387,7 @@ fn printErrsMsgToStdErr(
.msg = try std.fmt.allocPrint(arena, "invalid byte: '{'}'", .{
std.zig.fmtEscapes(tree.source[byte_offset..][0..1]),
}),
- .byte_offset = byte_offset,
+ .span = .{ .start = byte_offset, .end = byte_offset + 1, .main = byte_offset },
.line = @intCast(u32, start_loc.line),
.column = @intCast(u32, start_loc.column) + bad_off,
.source_line = source_line,
@@ -4402,11 +4402,16 @@ fn printErrsMsgToStdErr(
text_buf.items.len = 0;
try tree.renderError(note, writer);
const note_loc = tree.tokenLocation(0, note.token);
+ const byte_offset = @intCast(u32, note_loc.line_start);
notes_buffer[notes_len] = .{
.src = .{
.src_path = path,
.msg = try arena.dupe(u8, text_buf.items),
- .byte_offset = @intCast(u32, note_loc.line_start),
+ .span = .{
+ .start = byte_offset,
+ .end = byte_offset + @intCast(u32, tree.tokenSlice(note.token).len),
+ .main = byte_offset,
+ },
.line = @intCast(u32, note_loc.line),
.column = @intCast(u32, note_loc.column),
.source_line = tree.source[note_loc.line_start..note_loc.line_end],
@@ -4417,11 +4422,16 @@ fn printErrsMsgToStdErr(
}
const extra_offset = tree.errorOffset(parse_error);
+ const byte_offset = @intCast(u32, start_loc.line_start) + extra_offset;
const message: Compilation.AllErrors.Message = .{
.src = .{
.src_path = path,
.msg = text,
- .byte_offset = @intCast(u32, start_loc.line_start) + extra_offset,
+ .span = .{
+ .start = byte_offset,
+ .end = byte_offset + @intCast(u32, tree.tokenSlice(lok_token).len),
+ .main = byte_offset,
+ },
.line = @intCast(u32, start_loc.line),
.column = @intCast(u32, start_loc.column) + extra_offset,
.source_line = source_line,