aboutsummaryrefslogtreecommitdiff
path: root/test/compile_errors.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-08-16 16:30:24 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-08-16 16:30:24 -0400
commitbf7b6fbbdb7d28c0d7dba3e17c46ce156712cfc8 (patch)
tree50ad2616948cf255982fb4138ee8757ff92b5c80 /test/compile_errors.zig
parentcbca6586e72a8adefb3d8923d0c0f4590f54bfd8 (diff)
downloadzig-bf7b6fbbdb7d28c0d7dba3e17c46ce156712cfc8.tar.gz
zig-bf7b6fbbdb7d28c0d7dba3e17c46ce156712cfc8.zip
add missing compile error for fn call bad implicit cast
when the function's return type handle is a pointer but the result location's result value type handle is not a pointer closes #3055
Diffstat (limited to 'test/compile_errors.zig')
-rw-r--r--test/compile_errors.zig34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/compile_errors.zig b/test/compile_errors.zig
index 7c9d8fae51..5eec78fa7f 100644
--- a/test/compile_errors.zig
+++ b/test/compile_errors.zig
@@ -3,6 +3,40 @@ const builtin = @import("builtin");
pub fn addCases(cases: *tests.CompileErrorContext) void {
cases.add(
+ "result location incompatibility mismatching handle_is_ptr (generic call)",
+ \\export fn entry() void {
+ \\ var damn = Container{
+ \\ .not_optional = getOptional(i32),
+ \\ };
+ \\}
+ \\pub fn getOptional(comptime T: type) ?T {
+ \\ return 0;
+ \\}
+ \\pub const Container = struct {
+ \\ not_optional: i32,
+ \\};
+ ,
+ "tmp.zig:3:36: error: expected type 'i32', found '?i32'",
+ );
+
+ cases.add(
+ "result location incompatibility mismatching handle_is_ptr",
+ \\export fn entry() void {
+ \\ var damn = Container{
+ \\ .not_optional = getOptional(),
+ \\ };
+ \\}
+ \\pub fn getOptional() ?i32 {
+ \\ return 0;
+ \\}
+ \\pub const Container = struct {
+ \\ not_optional: i32,
+ \\};
+ ,
+ "tmp.zig:3:36: error: expected type 'i32', found '?i32'",
+ );
+
+ cases.add(
"const frame cast to anyframe",
\\export fn a() void {
\\ const f = async func();