Prevent using multiple class_name in a class
This commit is contained in:
parent
b7cf4c2050
commit
c07b49280a
2 changed files with 9 additions and 1 deletions
|
@ -3372,7 +3372,7 @@ void GDScriptParser::_parse_extends(ClassNode *p_class) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!p_class->constant_expressions.empty() || !p_class->subclasses.empty() || !p_class->functions.empty() || !p_class->variables.empty()) {
|
if (!p_class->constant_expressions.empty() || !p_class->subclasses.empty() || !p_class->functions.empty() || !p_class->variables.empty() || p_class->classname_used) {
|
||||||
|
|
||||||
_set_error("'extends' must be used before anything else.");
|
_set_error("'extends' must be used before anything else.");
|
||||||
return;
|
return;
|
||||||
|
@ -3509,6 +3509,12 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
|
||||||
_set_error("'class_name' syntax: 'class_name <UniqueName>'");
|
_set_error("'class_name' syntax: 'class_name <UniqueName>'");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (p_class->classname_used) {
|
||||||
|
_set_error("'class_name' already used for this class.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
p_class->classname_used = true;
|
||||||
|
|
||||||
p_class->name = tokenizer->get_token_identifier(1);
|
p_class->name = tokenizer->get_token_identifier(1);
|
||||||
|
|
||||||
|
|
|
@ -149,6 +149,7 @@ public:
|
||||||
bool tool;
|
bool tool;
|
||||||
StringName name;
|
StringName name;
|
||||||
bool extends_used;
|
bool extends_used;
|
||||||
|
bool classname_used;
|
||||||
StringName extends_file;
|
StringName extends_file;
|
||||||
Vector<StringName> extends_class;
|
Vector<StringName> extends_class;
|
||||||
DataType base_type;
|
DataType base_type;
|
||||||
|
@ -198,6 +199,7 @@ public:
|
||||||
tool = false;
|
tool = false;
|
||||||
type = TYPE_CLASS;
|
type = TYPE_CLASS;
|
||||||
extends_used = false;
|
extends_used = false;
|
||||||
|
classname_used = false;
|
||||||
end_line = -1;
|
end_line = -1;
|
||||||
owner = NULL;
|
owner = NULL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue