diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-02-06 17:49:37 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-02-06 17:49:37 +0100 |
commit | eee343210dd3eaf5fb149ca7a86371154032e47e (patch) | |
tree | 34ba69d1f8fb5f5899cb360cf2983cf4490dbd22 /modules/gdscript/gdscript_parser.cpp | |
parent | 6736b003542a655e71d02f109f36dbb5ba50e458 (diff) | |
parent | 2b60d9d6e1850616aabb0a8873757708940dd573 (diff) |
Merge pull request #72330 from MinusKube/unreachable_code_bug
Fix unreachable code warning for elif block
Diffstat (limited to 'modules/gdscript/gdscript_parser.cpp')
-rw-r--r-- | modules/gdscript/gdscript_parser.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index acc3c5d079..2ec7f77201 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -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)"); |