add tests for bad implicit casting of anyframe types

See #3063
master
Andrew Kelley 2019-08-16 11:00:21 -04:00
parent 4ea2331e3d
commit 7798054b58
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9
1 changed files with 21 additions and 0 deletions

View File

@ -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 {