Merge pull request #105413 from HolonProduction/gdscript-recover-match

GDScript: Do phrase level recovery for match
This commit is contained in:
Thaddeus Crews 2025-05-23 09:46:10 -05:00
commit ee82adcf04
No known key found for this signature in database
GPG key ID: 8C6E5FEB5FC03CCC
16 changed files with 100 additions and 1 deletions

View file

@ -2421,8 +2421,16 @@ GDScriptParser::MatchBranchNode *GDScriptParser::parse_match_branch() {
}
if (!consume(GDScriptTokenizer::Token::COLON, vformat(R"(Expected ":"%s after "match" %s.)", has_guard ? "" : R"( or "when")", has_guard ? "pattern guard" : "patterns"))) {
branch->block = alloc_recovery_suite();
complete_extents(branch);
return nullptr;
// Consume the whole line and treat the next one as new match branch.
while (current.type != GDScriptTokenizer::Token::NEWLINE && !is_at_end()) {
advance();
}
if (!is_at_end()) {
advance();
}
return branch;
}
SuiteNode *suite = alloc_node<SuiteNode>();