GDScript: Properly track extents of constants and patterns

Even in the case of errors.
This commit is contained in:
George Marques 2023-07-10 14:10:57 -03:00
parent ef155c1aeb
commit cbfe2b61b6
No known key found for this signature in database
GPG Key ID: 046BD46A3201E43D
1 changed files with 2 additions and 0 deletions

View File

@ -1139,6 +1139,7 @@ GDScriptParser::ConstantNode *GDScriptParser::parse_constant(bool p_is_static) {
ConstantNode *constant = alloc_node<ConstantNode>(); ConstantNode *constant = alloc_node<ConstantNode>();
if (!consume(GDScriptTokenizer::Token::IDENTIFIER, R"(Expected constant name after "const".)")) { if (!consume(GDScriptTokenizer::Token::IDENTIFIER, R"(Expected constant name after "const".)")) {
complete_extents(constant);
return nullptr; return nullptr;
} }
@ -2147,6 +2148,7 @@ GDScriptParser::PatternNode *GDScriptParser::parse_match_pattern(PatternNode *p_
ExpressionNode *expression = parse_expression(false); ExpressionNode *expression = parse_expression(false);
if (expression == nullptr) { if (expression == nullptr) {
push_error(R"(Expected expression for match pattern.)"); push_error(R"(Expected expression for match pattern.)");
complete_extents(pattern);
return nullptr; return nullptr;
} else { } else {
if (expression->type == GDScriptParser::Node::LITERAL) { if (expression->type == GDScriptParser::Node::LITERAL) {