Improve GDScript "unexpected token in class body" parser error

This parser error was misleading.

Fixes:
1. Now points at correct line
2. For identifiers, prints out `Identifier "%s"`
This commit is contained in:
JackErb 2024-11-30 14:29:30 -08:00
parent 893bbdfde8
commit 13fcb05e7b
5 changed files with 20 additions and 1 deletions

View file

@ -1060,8 +1060,8 @@ void GDScriptParser::parse_class_body(bool p_is_multiline) {
default:
// Display a completion with identifiers.
make_completion_context(COMPLETION_IDENTIFIER, nullptr);
push_error(vformat(R"(Unexpected "%s" in class body.)", current.get_name()));
advance();
push_error(vformat(R"(Unexpected %s in class body.)", previous.get_debug_name()));
break;
}
if (token.type != GDScriptTokenizer::Token::STATIC) {