Skip to content

Commit

Permalink
Merge pull request #72330 from MinusKube/unreachable_code_bug
Browse files Browse the repository at this point in the history
Fix unreachable code warning for elif block
  • Loading branch information
akien-mga committed Feb 6, 2023
2 parents 6736b00 + 2b60d9d commit eee3432
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions modules/gdscript/gdscript_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1833,10 +1833,18 @@ GDScriptParser::IfNode *GDScriptParser::parse_if(const String &p_token) {

if (match(GDScriptTokenizer::Token::ELIF)) {
SuiteNode *else_block = alloc_node<SuiteNode>();
else_block->parent_function = current_function;
else_block->parent_block = current_suite;

SuiteNode *previous_suite = current_suite;
current_suite = else_block;

IfNode *elif = parse_if("elif");
else_block->statements.push_back(elif);
complete_extents(else_block);
n_if->false_block = else_block;

current_suite = previous_suite;
} else if (match(GDScriptTokenizer::Token::ELSE)) {
consume(GDScriptTokenizer::Token::COLON, R"(Expected ":" after "else".)");
n_if->false_block = parse_suite(R"("else" block)");
Expand Down

0 comments on commit eee3432

Please sign in to comment.