typecheck the panic function

this adds the prototype of panic to @import("builtin")
and then uses it to do an implicit cast of the panic
function to this prototype, rather than redoing all the
implicit cast logic.

closes #1894
closes #1895
This commit is contained in:
Andrew Kelley
2019-02-15 19:19:28 -05:00
parent 7293e012d7
commit a05e224150
7 changed files with 50 additions and 48 deletions

View File

@@ -346,13 +346,23 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
);
cases.add(
"Panic declared with wrong type signature in tests",
"wrong panic signature, runtime function",
\\test "" {}
\\
\\pub fn panic() void {}
\\
,
".tmp_source.zig:3:5: error: expected 'fn([]const u8, ?*builtin.StackTrace) noreturn', found 'fn() void'",
".tmp_source.zig:3:5: error: expected type 'fn([]const u8, ?*StackTrace) noreturn', found 'fn() void'",
);
cases.add(
"wrong panic signature, generic function",
\\pub fn panic(comptime msg: []const u8, error_return_trace: ?*builtin.StackTrace) noreturn {
\\ while (true) {}
\\}
,
".tmp_source.zig:1:5: error: expected type 'fn([]const u8, ?*StackTrace) noreturn', found 'fn([]const u8,var)var'",
".tmp_source.zig:1:5: note: only one of the functions is generic",
);
cases.add(