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,...@@ -1790,7 +1790,8 @@ static LLVMValueRef ir_render_bin_op(CodeGen *g, IrExecutable *executable,
17901790
1791 assert(op1->value.type == op2->value.type || op_id == IrBinOpBitShiftLeftLossy ||1791 assert(op1->value.type == op2->value.type || op_id == IrBinOpBitShiftLeftLossy ||
1792 op_id == IrBinOpBitShiftLeftExact || op_id == IrBinOpBitShiftRightLossy ||1792 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));
1794 TypeTableEntry *type_entry = op1->value.type;1795 TypeTableEntry *type_entry = op1->value.type;
17951796
1796 bool want_runtime_safety = bin_op_instruction->safety_check_on &&1797 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...@@ -7258,8 +7258,8 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
7258 continue;7258 continue;
7259 }7259 }
7260 // unset all the errors7260 // unset all the errors
7261 for (uint32_t i = 0; i < prev_err_set_type->data.error_set.err_count; i += 1) {7261 for (uint32_t i = 0; i < err_set_type->data.error_set.err_count; i += 1) {
7262 ErrorTableEntry *error_entry = prev_err_set_type->data.error_set.errors[i];7262 ErrorTableEntry *error_entry = err_set_type->data.error_set.errors[i];
7263 errors[error_entry->value] = nullptr;7263 errors[error_entry->value] = nullptr;
7264 }7264 }
7265 for (uint32_t i = 0; i < cur_err_set_type->data.error_set.err_count; i += 1) {7265 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...@@ -7320,6 +7320,19 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod
7320 if (cur_type->id == TypeTableEntryIdErrorUnion &&7320 if (cur_type->id == TypeTableEntryIdErrorUnion &&
7321 types_match_const_cast_only(ira, cur_type->data.error_union.payload_type, prev_type, source_node).id == ConstCastResultIdOk)7321 types_match_const_cast_only(ira, cur_type->data.error_union.payload_type, prev_type, source_node).id == ConstCastResultIdOk)
7322 {7322 {
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 }
7323 prev_inst = cur_inst;7336 prev_inst = cur_inst;
7324 continue;7337 continue;
7325 }7338 }
std/debug/index.zig+2-2
...@@ -264,7 +264,7 @@ pub fn openSelfDebugInfo(allocator: &mem.Allocator) !&ElfStackTrace {...@@ -264,7 +264,7 @@ pub fn openSelfDebugInfo(allocator: &mem.Allocator) !&ElfStackTrace {
264 }264 }
265}265}
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 {
268 var f = try io.File.openRead(line_info.file_name, allocator);268 var f = try io.File.openRead(line_info.file_name, allocator);
269 defer f.close();269 defer f.close();
270 // TODO fstat and make sure that the file has the correct size270 // TODO fstat and make sure that the file has the correct size
...@@ -1054,7 +1054,7 @@ fn readULeb128(in_stream: var) !u64 {...@@ -1054,7 +1054,7 @@ fn readULeb128(in_stream: var) !u64 {
1054 }1054 }
1055}1055}
10561056
1057fn readILeb128(in_stream: &io.InStream) !i64 {1057fn readILeb128(in_stream: var) !i64 {
1058 var result: i64 = 0;1058 var result: i64 = 0;
1059 var shift: usize = 0;1059 var shift: usize = 0;
10601060