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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user