diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-02-05 07:38:24 -0500 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-02-05 07:38:24 -0500 |
| commit | b7bc259093ccad98cdc5661c493c0bdb4771e899 (patch) | |
| tree | 8f7730bdc0e79c240309ec4394b3c3e977d36653 /src/ir.cpp | |
| parent | 893f1088dfe40b0141ac6988a1ae6b165f7cc643 (diff) | |
| download | zig-b7bc259093ccad98cdc5661c493c0bdb4771e899.tar.gz zig-b7bc259093ccad98cdc5661c493c0bdb4771e899.zip | |
make OutStream and InStream take an error set param
Diffstat (limited to 'src/ir.cpp')
| -rw-r--r-- | src/ir.cpp | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/src/ir.cpp b/src/ir.cpp index aa3bc62988..3f3dfb1ad7 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -7174,32 +7174,37 @@ static TypeTableEntry *ir_resolve_peer_types(IrAnalyze *ira, AstNode *source_nod return ira->codegen->builtin_types.entry_invalid; } if (err_set_type == nullptr) { - err_set_type = cur_type; + if (prev_type->id == TypeTableEntryIdErrorUnion) { + err_set_type = prev_type->data.error_union.err_set_type; + } else { + err_set_type = cur_type; + } errors = allocate<ErrorTableEntry *>(ira->codegen->errors_by_index.length); for (uint32_t i = 0; i < err_set_type->data.error_set.err_count; i += 1) { ErrorTableEntry *error_entry = err_set_type->data.error_set.errors[i]; errors[error_entry->value] = error_entry; } - continue; - } else { - // check if the cur type error set is a subset - bool prev_is_superset = true; - for (uint32_t i = 0; i < cur_type->data.error_set.err_count; i += 1) { - ErrorTableEntry *contained_error_entry = cur_type->data.error_set.errors[i]; - ErrorTableEntry *error_entry = errors[contained_error_entry->value]; - if (error_entry == nullptr) { - prev_is_superset = false; - break; - } - } - if (prev_is_superset) { + if (err_set_type == cur_type) { continue; } - // not a subset. invent new error set type, union of both of them - err_set_type = get_error_set_union(ira->codegen, errors, err_set_type, cur_type); - assert(errors != nullptr); + } + // check if the cur type error set is a subset + bool prev_is_superset = true; + for (uint32_t i = 0; i < cur_type->data.error_set.err_count; i += 1) { + ErrorTableEntry *contained_error_entry = cur_type->data.error_set.errors[i]; + ErrorTableEntry *error_entry = errors[contained_error_entry->value]; + if (error_entry == nullptr) { + prev_is_superset = false; + break; + } + } + if (prev_is_superset) { continue; } + // not a subset. invent new error set type, union of both of them + err_set_type = get_error_set_union(ira->codegen, errors, err_set_type, cur_type); + assert(errors != nullptr); + continue; } if (prev_type->id == TypeTableEntryIdErrorUnion && cur_type->id == TypeTableEntryIdErrorUnion) { |
