Skip to content

Commit

Permalink
add tests for bad implicit casting of anyframe types
Browse files Browse the repository at this point in the history
See #3063
  • Loading branch information
andrewrk committed Aug 16, 2019
1 parent 4ea2331 commit 7798054
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/compile_errors.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,27 @@ const tests = @import("tests.zig");
const builtin = @import("builtin");

pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.add(
"prevent bad implicit casting of anyframe types",
\\export fn a() void {
\\ var x: anyframe = undefined;
\\ var y: anyframe->i32 = x;
\\}
\\export fn b() void {
\\ var x: i32 = undefined;
\\ var y: anyframe->i32 = x;
\\}
\\export fn c() void {
\\ var x: @Frame(func) = undefined;
\\ var y: anyframe->i32 = &x;
\\}
\\fn func() void {}
,
"tmp.zig:3:28: error: expected type 'anyframe->i32', found 'anyframe'",
"tmp.zig:7:28: error: expected type 'anyframe->i32', found 'i32'",
"tmp.zig:11:29: error: expected type 'anyframe->i32', found '*@Frame(func)'",
);

cases.add(
"wrong frame type used for async call",
\\export fn entry() void {
Expand Down

0 comments on commit 7798054

Please sign in to comment.