| author | |
| committer | |
| log | 5b7ae86af488745fc93cdbaff11bf2438938274a |
| tree | 1848e0b2e96ea622f4a6fc8f1bb31c7721331100 |
| parent | 517e8ea4269fb832f29d9eab642d57f1a8371149 |
closes #7122 files changed, 14 insertions(+), 1 deletions(-)
src/ir.cpp+5-1| ... | @@ -4992,7 +4992,11 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * | ... | @@ -4992,7 +4992,11 @@ static IrInstruction *ir_gen_switch_expr(IrBuilder *irb, Scope *scope, AstNode * |
| 4992 | 4992 | ||
| 4993 | ir_set_cursor_at_end_and_append_block(irb, end_block); | 4993 | ir_set_cursor_at_end_and_append_block(irb, end_block); |
| 4994 | assert(incoming_blocks.length == incoming_values.length); | 4994 | assert(incoming_blocks.length == incoming_values.length); |
| 4995 | return ir_build_phi(irb, scope, node, incoming_blocks.length, incoming_blocks.items, incoming_values.items); | 4995 | if (incoming_blocks.length == 0) { |
| 4996 | return ir_build_const_void(irb, scope, node); | ||
| 4997 | } else { | ||
| 4998 | return ir_build_phi(irb, scope, node, incoming_blocks.length, incoming_blocks.items, incoming_values.items); | ||
| 4999 | } | ||
| 4996 | } | 5000 | } |
| 4997 | 5001 | ||
| 4998 | static IrInstruction *ir_gen_comptime(IrBuilder *irb, Scope *parent_scope, AstNode *node, LVal lval) { | 5002 | static IrInstruction *ir_gen_comptime(IrBuilder *irb, Scope *parent_scope, AstNode *node, LVal lval) { |
test/compile_errors.zig+9| ... | @@ -1,6 +1,15 @@ | ... | @@ -1,6 +1,15 @@ |
| 1 | const tests = @import("tests.zig"); | 1 | const tests = @import("tests.zig"); |
| 2 | 2 | ||
| 3 | pub fn addCases(cases: &tests.CompileErrorContext) { | 3 | pub fn addCases(cases: &tests.CompileErrorContext) { |
| 4 | cases.add("switch on enum with 1 field with no prongs", | ||
| 5 | \\const Foo = enum { M }; | ||
| 6 | \\ | ||
| 7 | \\export fn entry() { | ||
| 8 | \\ var f = Foo.M; | ||
| 9 | \\ switch (f) {} | ||
| 10 | \\} | ||
| 11 | , ".tmp_source.zig:5:5: error: enumeration value 'Foo.M' not handled in switch"); | ||
| 12 | |||
| 4 | cases.add("shift by negative comptime integer", | 13 | cases.add("shift by negative comptime integer", |
| 5 | \\comptime { | 14 | \\comptime { |
| 6 | \\ var a = 1 >> -1; | 15 | \\ var a = 1 >> -1; |