| author | |
| committer | |
| log | 379d547603badb2667089c85454a2e3f5ede3342 |
| tree | 47904e8bd6afaeb594247039513141287f040457 |
| parent | 0e405c5fc52945a03711454e86c1caa7c72c4d02 |
| signature | Commit is signed but in an unrecognized format. |
2 files changed, 18 insertions(+), 0 deletions(-)
src/ir.cpp+5| ... | ... | @@ -17520,6 +17520,11 @@ static IrInstruction *ir_analyze_fn_call(IrAnalyze *ira, IrInstructionCallSrc *c |
| 17520 | 17520 | if (!handle_is_ptr(result_loc->value->type->data.pointer.child_type)) { |
| 17521 | 17521 | ir_reset_result(call_instruction->result_loc); |
| 17522 | 17522 | result_loc = nullptr; |
| 17523 | } else { | |
| 17524 | call_instruction->base.value.type = impl_fn_type_id->return_type; | |
| 17525 | IrInstruction *casted_value = ir_implicit_cast(ira, &call_instruction->base, result_loc->value.type->data.pointer.child_type); | |
| 17526 | if (type_is_invalid(casted_value->value.type)) | |
| 17527 | return casted_value; | |
| 17523 | 17528 | } |
| 17524 | 17529 | } |
| 17525 | 17530 | } else if (call_instruction->is_async_call_builtin) { |
test/compile_errors.zig+13| ... | ... | @@ -109,6 +109,19 @@ pub fn addCases(cases: *tests.CompileErrorContext) void { |
| 109 | 109 | "tmp.zig:3:17: error: expected type '[4]f32', found '[16]f32'" |
| 110 | 110 | ); |
| 111 | 111 | |
| 112 | cases.add( | |
| 113 | "generic function call assigned to incorrect type", | |
| 114 | \\pub export fn entry() void { | |
| 115 | \\ var res: []i32 = undefined; | |
| 116 | \\ res = myAlloc(i32); | |
| 117 | \\} | |
| 118 | \\fn myAlloc(comptime arg: type) anyerror!arg{ | |
| 119 | \\ unreachable; | |
| 120 | \\} | |
| 121 | , | |
| 122 | "tmp.zig:3:18: error: expected type '[]i32', found 'anyerror!i32" | |
| 123 | ); | |
| 124 | ||
| 112 | 125 | cases.add( |
| 113 | 126 | "asigning to struct or union fields that are not optionals with a function that returns an optional", |
| 114 | 127 | \\fn maybe(is: bool) ?u8 { |