authorgravatar for thejoshwolfe@gmail.comJosh Wolfe <thejoshwolfe@gmail.com> 2017-04-23 08:34:18-07:00
committergravatar for thejoshwolfe@gmail.comJosh Wolfe <thejoshwolfe@gmail.com> 2017-04-23 08:36:21-07:00
log14dfbd6ad39dadbd8505957b031f67bcd1a7b8a4
tree5aa31909123e29936445082720c9521b6a1c8443
parent8299fe19c056e9bae6f87a8281741d1e90019993

remove redundant unreachable code error


2 files changed, 2 insertions(+), 11 deletions(-)

src/ir.cpp+1-10
......@@ -3387,15 +3387,6 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode
33873387 continue;
33883388 }
33893389
3390 if (is_continuation_unreachable) {
3391 // if you put a semicolon after a return statement,
3392 // then we get a void statement in the unreachable area.
3393 // this is fine. ignore any void blocks we get from this happening.
3394 if (statement_node->type == NodeTypeBlock && statement_node->data.block.statements.length == 0)
3395 continue;
3396 add_node_error(irb->codegen, statement_node, buf_sprintf("unreachable code"));
3397 }
3398
33993390 IrInstruction *statement_value = ir_gen_node(irb, statement_node, child_scope);
34003391 is_continuation_unreachable = instr_is_unreachable(statement_value);
34013392 if (is_continuation_unreachable)
......@@ -3411,7 +3402,7 @@ static IrInstruction *ir_gen_block(IrBuilder *irb, Scope *parent_scope, AstNode
34113402 IrInstructionDeclVar *decl_var_instruction = (IrInstructionDeclVar *)statement_value;
34123403 child_scope = decl_var_instruction->var->child_scope;
34133404 } else {
3414 // label, defer, variable declaration will never be the last statement
3405 // label, defer, variable declaration will never be the result expression
34153406 if (block_node->data.block.last_statement_is_result_expression &&
34163407 i == block_node->data.block.statements.length - 1) {
34173408 // this is the result value statement
test/compile_errors.zig+1-1
......@@ -254,7 +254,7 @@ pub fn addCases(cases: &tests.CompileErrorContext) {
254254 \\}
255255 \\
256256 \\fn b() {}
257 , ".tmp_source.zig:3:6: error: unreachable code");
257 , ".tmp_source.zig:3:5: error: unreachable code");
258258
259259 cases.add("bad import",
260260 \\const bogus = @import("bogus-does-not-exist.zig");