diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-06-11 13:44:09 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-06-11 13:44:09 -0400 |
| commit | 1c2e889820e50e26654990750ac5ef0755996618 (patch) | |
| tree | a5e6a7e36444a424ed93d5ab58964f7af78d7060 /src/ir.cpp | |
| parent | fc8d8812404e79716e15fd301058032485e8bb64 (diff) | |
| download | zig-1c2e889820e50e26654990750ac5ef0755996618.tar.gz zig-1c2e889820e50e26654990750ac5ef0755996618.zip | |
fix struct and array init when result casted to anyerror!?T
previous commit message is incorrect, it was only for
anyerror!T
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index b841f8032f..0b9956253e 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -14951,7 +14951,14 @@ static IrInstruction *ir_analyze_instruction_resolve_result(IrAnalyze *ira, IrIn if (actual_elem_type->id == ZigTypeIdOptional && implicit_elem_type->id != ZigTypeIdOptional) { return ir_analyze_unwrap_optional_payload(ira, &instruction->base, result_loc, false, true); } else if (actual_elem_type->id == ZigTypeIdErrorUnion && implicit_elem_type->id != ZigTypeIdErrorUnion) { - return ir_analyze_unwrap_error_payload(ira, &instruction->base, result_loc, false, true); + IrInstruction *unwrapped_err_ptr = ir_analyze_unwrap_error_payload(ira, &instruction->base, + result_loc, false, true); + ZigType *actual_payload_type = actual_elem_type->data.error_union.payload_type; + if (actual_payload_type->id == ZigTypeIdOptional && implicit_elem_type->id != ZigTypeIdOptional) { + return ir_analyze_unwrap_optional_payload(ira, &instruction->base, unwrapped_err_ptr, false, true); + } else { + return unwrapped_err_ptr; + } } return result_loc; } |
