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
This commit is contained in:
Andrew Kelley
2019-08-16 16:30:24 -04:00
parent cbca6586e7
commit bf7b6fbbdb
2 changed files with 55 additions and 7 deletions

View File

@@ -2,6 +2,40 @@ const tests = @import("tests.zig");
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 {