From 7798054b5880860fba410b2cd12626455ef4394b Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 16 Aug 2019 11:00:21 -0400 Subject: [PATCH] add tests for bad implicit casting of anyframe types See #3063 --- test/compile_errors.zig | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/compile_errors.zig b/test/compile_errors.zig index 42cead93c..b00f09078 100644 --- a/test/compile_errors.zig +++ b/test/compile_errors.zig @@ -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 {