From 1566ca21c4bbe7f5aa5f385c7ebc22c780e54c8f Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Sat, 17 Jun 2017 10:28:42 -0400 Subject: fix peer type resolution for array and error closes #388 --- src/ir.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/ir.cpp') diff --git a/src/ir.cpp b/src/ir.cpp index c327722612..d1f14baf8e 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -6460,6 +6460,9 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod prev_inst = cur_inst; continue; } else if (cur_type->id == TypeTableEntryIdPureError) { + if (prev_type->id == TypeTableEntryIdArray) { + convert_to_const_slice = true; + } any_are_pure_error = true; continue; } else if (cur_type->id == TypeTableEntryIdNullLit) { @@ -6568,7 +6571,12 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod } if (convert_to_const_slice) { assert(prev_inst->value.type->id == TypeTableEntryIdArray); - return get_slice_type(ira->codegen, prev_inst->value.type->data.array.child_type, true); + TypeTableEntry *slice_type = get_slice_type(ira->codegen, prev_inst->value.type->data.array.child_type, true); + if (any_are_pure_error) { + return get_error_type(ira->codegen, slice_type); + } else { + return slice_type; + } } else if (any_are_pure_error && prev_inst->value.type->id != TypeTableEntryIdPureError) { if (prev_inst->value.type->id == TypeTableEntryIdNumLitInt || prev_inst->value.type->id == TypeTableEntryIdNumLitFloat) -- cgit v1.2.3