diff options
author | Rémi Verschelde <remi@verschelde.fr> | 2023-01-29 02:45:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-29 02:45:48 +0100 |
commit | a3dae9e548e5fbab7b7be070cf71f972656f759b (patch) | |
tree | bacf04c8cf902580022d94e707225c57dff561cb /modules/gdscript/gdscript_parser.cpp | |
parent | d866d6cd1bc79539a793611afa1ea8cf6cce2e6e (diff) | |
parent | c68b2358d58c9acd09dc9618bb7ba89246d759f7 (diff) | |
download | redot-engine-a3dae9e548e5fbab7b7be070cf71f972656f759b.tar.gz |
Merge pull request #72285 from vnen/gdscript-variable-match
GDScript: Allow variables in match patterns
Diffstat (limited to 'modules/gdscript/gdscript_parser.cpp')
-rw-r--r-- | modules/gdscript/gdscript_parser.cpp | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 1a744d59ba..74d7f94d7c 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -1904,7 +1904,6 @@ GDScriptParser::MatchNode *GDScriptParser::parse_match() { #ifdef DEBUG_ENABLED bool all_have_return = true; bool have_wildcard = false; - bool have_wildcard_without_continue = false; #endif while (!check(GDScriptTokenizer::Token::DEDENT) && !is_at_end()) { @@ -1915,19 +1914,12 @@ GDScriptParser::MatchNode *GDScriptParser::parse_match() { } #ifdef DEBUG_ENABLED - if (have_wildcard_without_continue && !branch->patterns.is_empty()) { + if (have_wildcard && !branch->patterns.is_empty()) { push_warning(branch->patterns[0], GDScriptWarning::UNREACHABLE_PATTERN); } - if (branch->has_wildcard) { - have_wildcard = true; - if (!branch->block->has_continue) { - have_wildcard_without_continue = true; - } - } - if (!branch->block->has_return) { - all_have_return = false; - } + have_wildcard = have_wildcard || branch->has_wildcard; + all_have_return = all_have_return && branch->block->has_return; #endif match->branches.push_back(branch); } |