| ... | @@ -364,7 +364,7 @@ const Eval = struct { | ... | @@ -364,7 +364,7 @@ const Eval = struct { |
| 364 | error_bundle.renderToStdErr(color.renderOptions()); | 364 | error_bundle.renderToStdErr(color.renderOptions()); |
| 365 | eval.fatal("update '{s}': more errors than expected", .{update.name}); | 365 | eval.fatal("update '{s}': more errors than expected", .{update.name}); |
| 366 | } | 366 | } |
| 367 | eval.checkOneError(update, error_bundle, expected.errors[expected_idx], false, err_idx); | 367 | try eval.checkOneError(update, error_bundle, expected.errors[expected_idx], false, err_idx); |
| 368 | expected_idx += 1; | 368 | expected_idx += 1; |
| 369 | | 369 | |
| 370 | for (error_bundle.getNotes(err_idx)) |note_idx| { | 370 | for (error_bundle.getNotes(err_idx)) |note_idx| { |
| ... | @@ -373,7 +373,7 @@ const Eval = struct { | ... | @@ -373,7 +373,7 @@ const Eval = struct { |
| 373 | error_bundle.renderToStdErr(color.renderOptions()); | 373 | error_bundle.renderToStdErr(color.renderOptions()); |
| 374 | eval.fatal("update '{s}': more error notes than expected", .{update.name}); | 374 | eval.fatal("update '{s}': more error notes than expected", .{update.name}); |
| 375 | } | 375 | } |
| 376 | eval.checkOneError(update, error_bundle, expected.errors[expected_idx], true, note_idx); | 376 | try eval.checkOneError(update, error_bundle, expected.errors[expected_idx], true, note_idx); |
| 377 | expected_idx += 1; | 377 | expected_idx += 1; |
| 378 | } | 378 | } |
| 379 | } | 379 | } |
| ... | @@ -392,13 +392,21 @@ const Eval = struct { | ... | @@ -392,13 +392,21 @@ const Eval = struct { |
| 392 | expected: Case.ExpectedError, | 392 | expected: Case.ExpectedError, |
| 393 | is_note: bool, | 393 | is_note: bool, |
| 394 | err_idx: std.zig.ErrorBundle.MessageIndex, | 394 | err_idx: std.zig.ErrorBundle.MessageIndex, |
| 395 | ) void { | 395 | ) Allocator.Error!void { |
| 396 | const err = eb.getErrorMessage(err_idx); | 396 | const err = eb.getErrorMessage(err_idx); |
| 397 | if (err.src_loc == .none) @panic("TODO error message with no source location"); | 397 | if (err.src_loc == .none) @panic("TODO error message with no source location"); |
| 398 | if (err.count != 1) @panic("TODO error message with count>1"); | 398 | if (err.count != 1) @panic("TODO error message with count>1"); |
| 399 | const msg = eb.nullTerminatedString(err.msg); | 399 | const msg = eb.nullTerminatedString(err.msg); |
| 400 | const src = eb.getSourceLocation(err.src_loc); | 400 | const src = eb.getSourceLocation(err.src_loc); |
| 401 | const filename = eb.nullTerminatedString(src.src_path); | 401 | const raw_filename = eb.nullTerminatedString(src.src_path); |
| | 402 | |
| | 403 | // We need to replace backslashes for consistency between platforms. |
| | 404 | const filename = name: { |
| | 405 | if (std.mem.indexOfScalar(u8, raw_filename, '\\') == null) break :name raw_filename; |
| | 406 | const copied = try eval.arena.dupe(u8, raw_filename); |
| | 407 | std.mem.replaceScalar(u8, copied, '\\', '/'); |
| | 408 | break :name copied; |
| | 409 | }; |
| 402 | | 410 | |
| 403 | if (expected.is_note != is_note or | 411 | if (expected.is_note != is_note or |
| 404 | !std.mem.eql(u8, expected.filename, filename) or | 412 | !std.mem.eql(u8, expected.filename, filename) or |