GDScript: Fix crash when superclass file is non-existent
Incidentally, allow EOF to be an end of statement.
This commit is contained in:
parent
fda6f3b600
commit
3abb3c0d6e
|
@ -85,6 +85,17 @@ Error GDScriptParserRef::raise_status(Status p_new_status) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (result != OK) {
|
||||||
|
if (parser != nullptr) {
|
||||||
|
memdelete(parser);
|
||||||
|
parser = nullptr;
|
||||||
|
}
|
||||||
|
if (analyzer != nullptr) {
|
||||||
|
memdelete(analyzer);
|
||||||
|
analyzer = nullptr;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -118,6 +129,10 @@ Ref<GDScriptParserRef> GDScriptCache::get_parser(const String &p_path, GDScriptP
|
||||||
if (singleton->parser_map.has(p_path)) {
|
if (singleton->parser_map.has(p_path)) {
|
||||||
ref = singleton->parser_map[p_path];
|
ref = singleton->parser_map[p_path];
|
||||||
} else {
|
} else {
|
||||||
|
if (!FileAccess::exists(p_path)) {
|
||||||
|
r_error = ERR_FILE_NOT_FOUND;
|
||||||
|
return ref;
|
||||||
|
}
|
||||||
GDScriptParser *parser = memnew(GDScriptParser);
|
GDScriptParser *parser = memnew(GDScriptParser);
|
||||||
ref.instance();
|
ref.instance();
|
||||||
ref->parser = parser;
|
ref->parser = parser;
|
||||||
|
|
|
@ -466,17 +466,17 @@ void GDScriptParser::pop_multiline() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GDScriptParser::is_statement_end() {
|
bool GDScriptParser::is_statement_end() {
|
||||||
return check(GDScriptTokenizer::Token::NEWLINE) || check(GDScriptTokenizer::Token::SEMICOLON);
|
return check(GDScriptTokenizer::Token::NEWLINE) || check(GDScriptTokenizer::Token::SEMICOLON) || check(GDScriptTokenizer::Token::TK_EOF);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GDScriptParser::end_statement(const String &p_context) {
|
void GDScriptParser::end_statement(const String &p_context) {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
while (is_statement_end()) {
|
while (is_statement_end() && !is_at_end()) {
|
||||||
// Remove sequential newlines/semicolons.
|
// Remove sequential newlines/semicolons.
|
||||||
found = true;
|
found = true;
|
||||||
advance();
|
advance();
|
||||||
}
|
}
|
||||||
if (!found) {
|
if (!found && !is_at_end()) {
|
||||||
push_error(vformat(R"(Expected end of statement after %s, found "%s" instead.)", p_context, current.get_name()));
|
push_error(vformat(R"(Expected end of statement after %s, found "%s" instead.)", p_context, current.get_name()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue