add missing cast to call result type
This commit is contained in:
parent
7de138ad7c
commit
0e405c5fc5
|
@ -17682,6 +17682,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c
|
|||
if (!handle_is_ptr(result_loc->value->type->data.pointer.child_type)) {
|
||||
ir_reset_result(call_instruction->result_loc);
|
||||
result_loc = nullptr;
|
||||
} else {
|
||||
call_instruction->base.value.type = return_type;
|
||||
IrInstruction *casted_value = ir_implicit_cast(ira, &call_instruction->base, result_loc->value.type->data.pointer.child_type);
|
||||
if (type_is_invalid(casted_value->value.type))
|
||||
return casted_value;
|
||||
}
|
||||
}
|
||||
} else if (call_instruction->is_async_call_builtin) {
|
||||
|
|
|
@ -96,6 +96,19 @@ pub fn addCases(cases: *tests.CompileErrorContext) void {
|
|||
"tmp.zig:11:25: error: expected type 'u32', found '@typeOf(get_uval).ReturnType.ErrorSet!u32'",
|
||||
);
|
||||
|
||||
cases.add(
|
||||
"function call assigned to incorrect type",
|
||||
\\export fn entry() void {
|
||||
\\ var arr: [4]f32 = undefined;
|
||||
\\ arr = concat();
|
||||
\\}
|
||||
\\fn concat() [16]f32 {
|
||||
\\ return [1]f32{0}**16;
|
||||
\\}
|
||||
,
|
||||
"tmp.zig:3:17: error: expected type '[4]f32', found '[16]f32'"
|
||||
);
|
||||
|
||||
cases.add(
|
||||
"asigning to struct or union fields that are not optionals with a function that returns an optional",
|
||||
\\fn maybe(is: bool) ?u8 {
|
||||
|
|
Loading…
Reference in New Issue
Block a user