mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
GDScript: Remove function of continue
for match statement
The keyword is confusing and rarely is used in the intended way. It is removed now in favor of a future feature (pattern guards) to avoid breaking compatibility later.
This commit is contained in:
parent
2ec0da1a75
commit
9462ae4783
10 changed files with 5 additions and 76 deletions
|
@ -1806,11 +1806,10 @@ GDScriptParser::BreakNode *GDScriptParser::parse_break() {
|
|||
|
||||
GDScriptParser::ContinueNode *GDScriptParser::parse_continue() {
|
||||
if (!can_continue) {
|
||||
push_error(R"(Cannot use "continue" outside of a loop or pattern matching block.)");
|
||||
push_error(R"(Cannot use "continue" outside of a loop.)");
|
||||
}
|
||||
current_suite->has_continue = true;
|
||||
ContinueNode *cont = alloc_node<ContinueNode>();
|
||||
cont->is_for_match = is_continue_match;
|
||||
complete_extents(cont);
|
||||
end_statement(R"("continue")");
|
||||
return cont;
|
||||
|
@ -1836,12 +1835,10 @@ GDScriptParser::ForNode *GDScriptParser::parse_for() {
|
|||
// Save break/continue state.
|
||||
bool could_break = can_break;
|
||||
bool could_continue = can_continue;
|
||||
bool was_continue_match = is_continue_match;
|
||||
|
||||
// Allow break/continue.
|
||||
can_break = true;
|
||||
can_continue = true;
|
||||
is_continue_match = false;
|
||||
|
||||
SuiteNode *suite = alloc_node<SuiteNode>();
|
||||
if (n_for->variable) {
|
||||
|
@ -1859,7 +1856,6 @@ GDScriptParser::ForNode *GDScriptParser::parse_for() {
|
|||
// Reset break/continue state.
|
||||
can_break = could_break;
|
||||
can_continue = could_continue;
|
||||
is_continue_match = was_continue_match;
|
||||
|
||||
return n_for;
|
||||
}
|
||||
|
@ -1996,13 +1992,6 @@ GDScriptParser::MatchBranchNode *GDScriptParser::parse_match_branch() {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
// Save continue state.
|
||||
bool could_continue = can_continue;
|
||||
bool was_continue_match = is_continue_match;
|
||||
// Allow continue for match.
|
||||
can_continue = true;
|
||||
is_continue_match = true;
|
||||
|
||||
SuiteNode *suite = alloc_node<SuiteNode>();
|
||||
if (branch->patterns.size() > 0) {
|
||||
for (const KeyValue<StringName, IdentifierNode *> &E : branch->patterns[0]->binds) {
|
||||
|
@ -2015,10 +2004,6 @@ GDScriptParser::MatchBranchNode *GDScriptParser::parse_match_branch() {
|
|||
branch->block = parse_suite("match pattern block", suite);
|
||||
complete_extents(branch);
|
||||
|
||||
// Restore continue state.
|
||||
can_continue = could_continue;
|
||||
is_continue_match = was_continue_match;
|
||||
|
||||
return branch;
|
||||
}
|
||||
|
||||
|
@ -2177,12 +2162,10 @@ GDScriptParser::WhileNode *GDScriptParser::parse_while() {
|
|||
// Save break/continue state.
|
||||
bool could_break = can_break;
|
||||
bool could_continue = can_continue;
|
||||
bool was_continue_match = is_continue_match;
|
||||
|
||||
// Allow break/continue.
|
||||
can_break = true;
|
||||
can_continue = true;
|
||||
is_continue_match = false;
|
||||
|
||||
n_while->loop = parse_suite(R"("while" block)");
|
||||
n_while->loop->is_loop = true;
|
||||
|
@ -2191,7 +2174,6 @@ GDScriptParser::WhileNode *GDScriptParser::parse_while() {
|
|||
// Reset break/continue state.
|
||||
can_break = could_break;
|
||||
can_continue = could_continue;
|
||||
is_continue_match = was_continue_match;
|
||||
|
||||
return n_while;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue