GDScript: Fix editor crash when writing @tool annotation
This commit is contained in:
parent
f374021d52
commit
d06ce2f11e
@ -494,16 +494,18 @@ void GDScriptParser::parse_program() {
|
|||||||
if (match(GDScriptTokenizer::Token::ANNOTATION)) {
|
if (match(GDScriptTokenizer::Token::ANNOTATION)) {
|
||||||
// Check for @tool annotation.
|
// Check for @tool annotation.
|
||||||
AnnotationNode *annotation = parse_annotation(AnnotationInfo::SCRIPT | AnnotationInfo::CLASS_LEVEL);
|
AnnotationNode *annotation = parse_annotation(AnnotationInfo::SCRIPT | AnnotationInfo::CLASS_LEVEL);
|
||||||
if (annotation->name == "@tool") {
|
if (annotation != nullptr) {
|
||||||
// TODO: don't allow @tool anywhere else. (Should all script annotations be the first thing?).
|
if (annotation->name == "@tool") {
|
||||||
_is_tool = true;
|
// TODO: don't allow @tool anywhere else. (Should all script annotations be the first thing?).
|
||||||
if (previous.type != GDScriptTokenizer::Token::NEWLINE) {
|
_is_tool = true;
|
||||||
push_error(R"(Expected newline after "@tool" annotation.)");
|
if (previous.type != GDScriptTokenizer::Token::NEWLINE) {
|
||||||
|
push_error(R"(Expected newline after "@tool" annotation.)");
|
||||||
|
}
|
||||||
|
// @tool annotation has no specific target.
|
||||||
|
annotation->apply(this, nullptr);
|
||||||
|
} else {
|
||||||
|
annotation_stack.push_back(annotation);
|
||||||
}
|
}
|
||||||
// @tool annotation has no specific target.
|
|
||||||
annotation->apply(this, nullptr);
|
|
||||||
} else {
|
|
||||||
annotation_stack.push_back(annotation);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user