Skip to content

Commit 7f7dd0d

Browse files
committed
Merge pull request #104636 from Meorge/feat/export-syntax-error
Add specific errors for use of keywords removed in Godot 4
2 parents b4e6ef3 + 5c662f7 commit 7f7dd0d

File tree

5 files changed

+35
-1
lines changed

5 files changed

+35
-1
lines changed

modules/gdscript/gdscript_parser.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,27 @@ void GDScriptParser::parse_class_body(bool p_is_multiline) {
10871087
// Display a completion with identifiers.
10881088
make_completion_context(COMPLETION_IDENTIFIER, nullptr);
10891089
advance();
1090-
push_error(vformat(R"(Unexpected %s in class body.)", previous.get_debug_name()));
1090+
if (previous.get_identifier() == "export") {
1091+
push_error(R"(The "export" keyword was removed in Godot 4. Use an export annotation ("@export", "@export_range", etc.) instead.)");
1092+
} else if (previous.get_identifier() == "tool") {
1093+
push_error(R"(The "tool" keyword was removed in Godot 4. Use the "@tool" annotation instead.)");
1094+
} else if (previous.get_identifier() == "onready") {
1095+
push_error(R"(The "onready" keyword was removed in Godot 4. Use the "@onready" annotation instead.)");
1096+
} else if (previous.get_identifier() == "remote") {
1097+
push_error(R"(The "remote" keyword was removed in Godot 4. Use the "@rpc" annotation with "any_peer" instead.)");
1098+
} else if (previous.get_identifier() == "remotesync") {
1099+
push_error(R"(The "remotesync" keyword was removed in Godot 4. Use the "@rpc" annotation with "any_peer" and "call_local" instead.)");
1100+
} else if (previous.get_identifier() == "puppet") {
1101+
push_error(R"(The "puppet" keyword was removed in Godot 4. Use the "@rpc" annotation with "authority" instead.)");
1102+
} else if (previous.get_identifier() == "puppetsync") {
1103+
push_error(R"(The "puppetsync" keyword was removed in Godot 4. Use the "@rpc" annotation with "authority" and "call_local" instead.)");
1104+
} else if (previous.get_identifier() == "master") {
1105+
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.)");
1106+
} else if (previous.get_identifier() == "mastersync") {
1107+
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.)");
1108+
} else {
1109+
push_error(vformat(R"(Unexpected %s in class body.)", previous.get_debug_name()));
1110+
}
10911111
break;
10921112
}
10931113
if (token.type != GDScriptTokenizer::Token::STATIC) {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export var test = 3
2+
3+
4+
func test():
5+
pass
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
GDTEST_PARSER_ERROR
2+
The "export" keyword was removed in Godot 4. Use an export annotation ("@export", "@export_range", etc.) instead.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export(int, "a", "b", "c") var test = 3
2+
3+
4+
func test():
5+
pass
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
GDTEST_PARSER_ERROR
2+
The "export" keyword was removed in Godot 4. Use an export annotation ("@export", "@export_range", etc.) instead.

0 commit comments

Comments
 (0)