Merge pull request #104636 from Meorge/feat/export-syntax-error

Add specific errors for use of keywords removed in Godot 4
This commit is contained in:
Thaddeus Crews
2025-04-25 11:36:07 -05:00
5 changed files with 35 additions and 1 deletions

View File

@ -1087,7 +1087,27 @@ void GDScriptParser::parse_class_body(bool p_is_multiline) {
// Display a completion with identifiers.
make_completion_context(COMPLETION_IDENTIFIER, nullptr);
advance();
if (previous.get_identifier() == "export") {
push_error(R"(The "export" keyword was removed in Godot 4. Use an export annotation ("@export", "@export_range", etc.) instead.)");
} else if (previous.get_identifier() == "tool") {
push_error(R"(The "tool" keyword was removed in Godot 4. Use the "@tool" annotation instead.)");
} else if (previous.get_identifier() == "onready") {
push_error(R"(The "onready" keyword was removed in Godot 4. Use the "@onready" annotation instead.)");
} else if (previous.get_identifier() == "remote") {
push_error(R"(The "remote" keyword was removed in Godot 4. Use the "@rpc" annotation with "any_peer" instead.)");
} else if (previous.get_identifier() == "remotesync") {
push_error(R"(The "remotesync" keyword was removed in Godot 4. Use the "@rpc" annotation with "any_peer" and "call_local" instead.)");
} else if (previous.get_identifier() == "puppet") {
push_error(R"(The "puppet" keyword was removed in Godot 4. Use the "@rpc" annotation with "authority" instead.)");
} else if (previous.get_identifier() == "puppetsync") {
push_error(R"(The "puppetsync" keyword was removed in Godot 4. Use the "@rpc" annotation with "authority" and "call_local" instead.)");
} else if (previous.get_identifier() == "master") {
push_error(R"(The "master" keyword was removed in Godot 4. Use the "@rpc" annotation with "any_peer" and perform a check inside the function instead.)");
} else if (previous.get_identifier() == "mastersync") {
push_error(R"(The "mastersync" keyword was removed in Godot 4. Use the "@rpc" annotation with "any_peer" and "call_local", and perform a check inside the function instead.)");
} else {
push_error(vformat(R"(Unexpected %s in class body.)", previous.get_debug_name()));
}
break;
}
if (token.type != GDScriptTokenizer::Token::STATIC) {

View File

@ -0,0 +1,5 @@
export var test = 3
func test():
pass

View File

@ -0,0 +1,2 @@
GDTEST_PARSER_ERROR
The "export" keyword was removed in Godot 4. Use an export annotation ("@export", "@export_range", etc.) instead.

View File

@ -0,0 +1,5 @@
export(int, "a", "b", "c") var test = 3
func test():
pass

View File

@ -0,0 +1,2 @@
GDTEST_PARSER_ERROR
The "export" keyword was removed in Godot 4. Use an export annotation ("@export", "@export_range", etc.) instead.