authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-05-31 20:48:04+03:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2020-05-31 20:48:04+03:00
logf5eb31a55a80f86029704c2126e0f0d4504a6393
treea28079b9f4a207bf1d703acac6364722943f0938
parentf5167f73e8765eaba6bd342cd81b0dbe2205519d
parent250dd9ac21ffcd2fe1dba6d0cdebcbb683c199a9
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #5491 from xackus/fix_5487

stage1: fix unresolved inferred error sets

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

src/ir.cpp+6-6
...@@ -18177,12 +18177,6 @@ static IrInstGen *ir_analyze_instruction_merge_err_sets(IrAnalyze *ira,...@@ -18177,12 +18177,6 @@ static IrInstGen *ir_analyze_instruction_merge_err_sets(IrAnalyze *ira,
18177 if (type_is_invalid(op2_type))18177 if (type_is_invalid(op2_type))
18178 return ira->codegen->invalid_inst_gen;18178 return ira->codegen->invalid_inst_gen;
1817918179
18180 if (type_is_global_error_set(op1_type) ||
18181 type_is_global_error_set(op2_type))
18182 {
18183 return ir_const_type(ira, &instruction->base.base, ira->codegen->builtin_types.entry_global_error_set);
18184 }
18185
18186 if (!resolve_inferred_error_set(ira->codegen, op1_type, instruction->op1->child->base.source_node)) {18180 if (!resolve_inferred_error_set(ira->codegen, op1_type, instruction->op1->child->base.source_node)) {
18187 return ira->codegen->invalid_inst_gen;18181 return ira->codegen->invalid_inst_gen;
18188 }18182 }
...@@ -18191,6 +18185,12 @@ static IrInstGen *ir_analyze_instruction_merge_err_sets(IrAnalyze *ira,...@@ -18191,6 +18185,12 @@ static IrInstGen *ir_analyze_instruction_merge_err_sets(IrAnalyze *ira,
18191 return ira->codegen->invalid_inst_gen;18185 return ira->codegen->invalid_inst_gen;
18192 }18186 }
1819318187
18188 if (type_is_global_error_set(op1_type) ||
18189 type_is_global_error_set(op2_type))
18190 {
18191 return ir_const_type(ira, &instruction->base.base, ira->codegen->builtin_types.entry_global_error_set);
18192 }
18193
18194 size_t errors_count = ira->codegen->errors_by_index.length;18194 size_t errors_count = ira->codegen->errors_by_index.length;
18195 ErrorTableEntry **errors = heap::c_allocator.allocate<ErrorTableEntry *>(errors_count);18195 ErrorTableEntry **errors = heap::c_allocator.allocate<ErrorTableEntry *>(errors_count);
18196 for (uint32_t i = 0, count = op1_type->data.error_set.err_count; i < count; i += 1) {18196 for (uint32_t i = 0, count = op1_type->data.error_set.err_count; i < count; i += 1) {
test/stage1/behavior.zig+1
...@@ -50,6 +50,7 @@ comptime {...@@ -50,6 +50,7 @@ comptime {
50 _ = @import("behavior/bugs/4769_b.zig");50 _ = @import("behavior/bugs/4769_b.zig");
51 _ = @import("behavior/bugs/4769_c.zig");51 _ = @import("behavior/bugs/4769_c.zig");
52 _ = @import("behavior/bugs/4954.zig");52 _ = @import("behavior/bugs/4954.zig");
53 _ = @import("behavior/bugs/5487.zig");
53 _ = @import("behavior/bugs/394.zig");54 _ = @import("behavior/bugs/394.zig");
54 _ = @import("behavior/bugs/421.zig");55 _ = @import("behavior/bugs/421.zig");
55 _ = @import("behavior/bugs/529.zig");56 _ = @import("behavior/bugs/529.zig");
test/stage1/behavior/bugs/5487.zig created+12
...@@ -0,0 +1,12 @@
1const io = @import("std").io;
2
3pub fn write(_: void, bytes: []const u8) !usize {
4 return 0;
5}
6pub fn outStream() io.OutStream(void, @TypeOf(write).ReturnType.ErrorSet, write) {
7 return io.OutStream(void, @TypeOf(write).ReturnType.ErrorSet, write){ .context = {} };
8}
9
10test "crash" {
11 _ = io.multiOutStream(.{outStream()});
12}