authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2019-11-17 16:55:38+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-17 22:25:14+00:00
log924dd674e2e584bbef5e7650f481e49829c8fe28
treefec5f00575cf95b8584e498683de9234fd4c9b9a
parent6cddf9d7238a58b88064c3f3ce6e3948143598d8

Catch invalid type from peer resolution

Fixes #3703

2 files changed, 14 insertions(+), 0 deletions(-)

src/ir.cpp+2
......@@ -17695,6 +17695,8 @@ static IrInstruction *ir_analyze_instruction_phi(IrAnalyze *ira, IrInstructionPh
1769517695 peer_parent->resolved_type = ir_resolve_peer_types(ira,
1769617696 peer_parent->base.source_instruction->source_node, expected_type, instructions,
1769717697 peer_parent->peers.length);
17698 if (type_is_invalid(peer_parent->resolved_type))
17699 return ira->codegen->invalid_instruction;
1769817700
1769917701 // the logic below assumes there are no instructions in the new current basic block yet
1770017702 ir_assert(ira->new_irb.current_basic_block->instruction_list.length == 0, &phi_instruction->base);
test/compile_errors.zig+12
......@@ -2,6 +2,18 @@ const tests = @import("tests.zig");
22const builtin = @import("builtin");
33
44pub fn addCases(cases: *tests.CompileErrorContext) void {
5 cases.add(
6 "missing result type for phi node",
7 \\fn foo() !void {
8 \\ return anyerror.Foo;
9 \\}
10 \\export fn entry() void {
11 \\ foo() catch 0;
12 \\}
13 ,
14 "tmp.zig:5:17: error: integer value 0 cannot be coerced to type 'void'",
15 );
16
517 cases.add(
618 "atomicrmw with enum op not .Xchg",
719 \\export fn entry() void {