authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-02-05 17:42:13-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-02-05 17:42:13-05:00
log6940212ecbef349e449441e1fd813116865d3a5f
tree02242395c35b7f209b1184bc1941acf2736520a9
parentb7bc259093ccad98cdc5661c493c0bdb4771e899

error sets: fix peer resolution of error unions


3 files changed, 19 insertions(+), 5 deletions(-)

src/codegen.cpp+2-1
......@@ -1790,7 +1790,8 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutable *executable,
17901790
17911791 assert(op1->value.type == op2->value.type || op_id == IrBinOpBitShiftLeftLossy ||
17921792 op_id == IrBinOpBitShiftLeftExact || op_id == IrBinOpBitShiftRightLossy ||
1793 op_id == IrBinOpBitShiftRightExact);
1793 op_id == IrBinOpBitShiftRightExact ||
1794 (op1->value.type->id == TypeTableEntryIdErrorSet && op2->value.type->id == TypeTableEntryIdErrorSet));
17941795 TypeTableEntry *type_entry = op1->value.type;
17951796
17961797 bool want_runtime_safety = bin_op_instruction->safety_check_on &&
src/ir.cpp+15-2
......@@ -7258,8 +7258,8 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
72587258 continue;
72597259 }
72607260 // unset all the errors
7261 for (uint32_t i = 0; i < prev_err_set_type->data.error_set.err_count; i += 1) {
7262 ErrorTableEntry *error_entry = prev_err_set_type->data.error_set.errors[i];
7261 for (uint32_t i = 0; i < err_set_type->data.error_set.err_count; i += 1) {
7262 ErrorTableEntry *error_entry = err_set_type->data.error_set.errors[i];
72637263 errors[error_entry->value] = nullptr;
72647264 }
72657265 for (uint32_t i = 0; i < cur_err_set_type->data.error_set.err_count; i += 1) {
......@@ -7320,6 +7320,19 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
73207320 if (cur_type->id == TypeTableEntryIdErrorUnion &&
73217321 types_match_const_cast_only(ira, cur_type->data.error_union.payload_type, prev_type, source_node).id == ConstCastResultIdOk)
73227322 {
7323 if (err_set_type != nullptr) {
7324 TypeTableEntry *cur_err_set_type = cur_type->data.error_union.err_set_type;
7325 if (!resolve_inferred_error_set(ira, cur_err_set_type, cur_inst->source_node)) {
7326 return ira->codegen->builtin_types.entry_invalid;
7327 }
7328 if (type_is_global_error_set(cur_err_set_type) || type_is_global_error_set(err_set_type)) {
7329 err_set_type = ira->codegen->builtin_types.entry_global_error_set;
7330 prev_inst = cur_inst;
7331 continue;
7332 }
7333
7334 err_set_type = get_error_set_union(ira->codegen, errors, err_set_type, cur_err_set_type);
7335 }
73237336 prev_inst = cur_inst;
73247337 continue;
73257338 }
std/debug/index.zig+2-2
......@@ -264,7 +264,7 @@ pub fn openSelfDebugInfo(allocator: &mem.Allocator) !&ElfStackTrace {
264264 }
265265}
266266
267fn printLineFromFile(allocator: &mem.Allocator, out_stream: &io.OutStream, line_info: &const LineInfo) !void {
267fn printLineFromFile(allocator: &mem.Allocator, out_stream: var, line_info: &const LineInfo) !void {
268268 var f = try io.File.openRead(line_info.file_name, allocator);
269269 defer f.close();
270270 // TODO fstat and make sure that the file has the correct size
......@@ -1054,7 +1054,7 @@ fn readULeb128(in_stream: var) !u64 {
10541054 }
10551055}
10561056
1057fn readILeb128(in_stream: &io.InStream) !i64 {
1057fn readILeb128(in_stream: var) !i64 {
10581058 var result: i64 = 0;
10591059 var shift: usize = 0;
10601060