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 committed 2024-12-09 21:01:46 -08:00
1 parent 893bbdfde8
commit 13fcb05e7b
5 files changed
+20 -1

No files matched your search

+1 -1
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) {