implement @call

closes #3732
This commit is contained in:
Andrew Kelley
2019-12-05 16:55:32 -05:00
parent 38791ac616
commit 1f602fe8c5
14 changed files with 529 additions and 188 deletions

View File

@@ -2,6 +2,24 @@ const tests = @import("tests.zig");
const builtin = @import("builtin");
pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.add(
"bad usage of @call",
\\export fn entry1() void {
\\ @call(.{}, foo, {});
\\}
\\export fn entry2() void {
\\ comptime @call(.{ .modifier = .never_inline }, foo, .{});
\\}
\\export fn entry3() void {
\\ comptime @call(.{ .modifier = .never_tail }, foo, .{});
\\}
\\fn foo() void {}
,
"tmp.zig:2:21: error: expected tuple or struct, found 'void'",
"tmp.zig:5:58: error: unable to perform 'never_inline' call at compile-time",
"tmp.zig:8:56: error: unable to perform 'never_tail' call at compile-time",
);
cases.add(
\\export async fn foo() void {}
, "tmp.zig:1:1: error: exported function cannot be async");