Merge pull request #71963 from dalexeev/clarify-script-level-annotation-error

Clarify error message about script-level annotation
This commit is contained in:
Rémi Verschelde 2023-01-25 09:17:03 +01:00
commit fc1610a063
No known key found for this signature in database
GPG key ID: C3336907360768E1
2 changed files with 6 additions and 2 deletions

View file

@ -1434,7 +1434,11 @@ GDScriptParser::AnnotationNode *GDScriptParser::parse_annotation(uint32_t p_vali
annotation->info = &valid_annotations[annotation->name];
if (!annotation->applies_to(p_valid_targets)) {
push_error(vformat(R"(Annotation "%s" is not allowed in this level.)", annotation->name));
if (annotation->applies_to(AnnotationInfo::SCRIPT)) {
push_error(vformat(R"(Annotation "%s" must be at the top of the script, before "extends" and "class_name".)", annotation->name));
} else {
push_error(vformat(R"(Annotation "%s" is not allowed in this level.)", annotation->name));
}
valid = false;
}

View file

@ -1,2 +1,2 @@
GDTEST_PARSER_ERROR
Annotation "@icon" is not allowed in this level.
Annotation "@icon" must be at the top of the script, before "extends" and "class_name".