Skip to content

Commit

Permalink
GDScript: Fix annotation parsing adding new annotation entries
Browse files Browse the repository at this point in the history
  • Loading branch information
HolonProduction committed Oct 13, 2024
1 parent 92e51fc commit a997e69
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
16 changes: 9 additions & 7 deletions modules/gdscript/gdscript_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1624,15 +1624,17 @@ GDScriptParser::AnnotationNode *GDScriptParser::parse_annotation(uint32_t p_vali
valid = false;
}

annotation->info = &valid_annotations[annotation->name];
if (valid) {
annotation->info = &valid_annotations[annotation->name];

if (!annotation->applies_to(p_valid_targets)) {
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));
if (!annotation->applies_to(p_valid_targets)) {
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;
}
valid = false;
}

if (check(GDScriptTokenizer::Token::PARENTHESIS_OPEN)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@export
func test():
pass
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GDTEST_PARSER_ERROR
Annotation "@export" cannot be applied to a function.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@hello_world
var test
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GDTEST_PARSER_ERROR
Unrecognized annotation: "@hello_world".

0 comments on commit a997e69

Please sign in to comment.