Compilation: indent multiline error messages properly

Co-authored-by: Veikka Tuominen <git@vexu.eu>
This commit is contained in:
r00ster91
2022-07-11 23:10:39 +02:00
committed by GitHub
parent ade9bd9287
commit da75eb0d79
3 changed files with 84 additions and 14 deletions

View File

@@ -138,6 +138,42 @@ pub fn addCases(ctx: *TestContext) !void {
"tmp.zig:2:1: error: invalid character: '\\t'",
});
{
const case = ctx.obj("multiline error messages", .{});
case.backend = .stage2;
case.addError(
\\comptime {
\\ @compileError("hello\nworld");
\\}
, &[_][]const u8{
\\:2:5: error: hello
\\ world
});
case.addError(
\\comptime {
\\ @compileError(
\\ \\
\\ \\hello!
\\ \\I'm a multiline error message.
\\ \\I hope to be very useful!
\\ \\
\\ \\also I will leave this trailing newline here if you don't mind
\\ \\
\\ );
\\}
, &[_][]const u8{
\\:2:5: error:
\\ hello!
\\ I'm a multiline error message.
\\ I hope to be very useful!
\\
\\ also I will leave this trailing newline here if you don't mind
\\
});
}
// TODO test this in stage2, but we won't even try in stage1
//ctx.objErrStage1("inline fn calls itself indirectly",
// \\export fn foo() void {