diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-05-28 11:56:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-28 11:56:21 +0200 |
commit | 633af46a66c5dfabdd6b7abcfd2800d24ee9a8f1 (patch) | |
tree | 663dd999399164b33bbff237108be28d3ac271db /modules/gdscript | |
parent | 58f66fa848ad0c810d688bec1b0b9081870adbde (diff) | |
parent | c07b49280aee24b07e0da7fd42dee4cba187cf13 (diff) |
Merge pull request #27987 from lupoDharkael/classname-duplicate
Prevent using multiple class_name in a class
Diffstat (limited to 'modules/gdscript')
-rw-r--r-- | modules/gdscript/gdscript_parser.cpp | 8 | ||||
-rw-r--r-- | modules/gdscript/gdscript_parser.h | 2 |
2 files changed, 9 insertions, 1 deletions
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 1c22c4af3c..9590009a54 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -3369,7 +3369,7 @@ void GDScriptParser::_parse_extends(ClassNode *p_class) { 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."); return; @@ -3506,6 +3506,12 @@ void GDScriptParser::_parse_class(ClassNode *p_class) { _set_error("'class_name' syntax: 'class_name <UniqueName>'"); 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); diff --git a/modules/gdscript/gdscript_parser.h b/modules/gdscript/gdscript_parser.h index 809bff8f20..5e4de11357 100644 --- a/modules/gdscript/gdscript_parser.h +++ b/modules/gdscript/gdscript_parser.h @@ -149,6 +149,7 @@ public: bool tool; StringName name; bool extends_used; + bool classname_used; StringName extends_file; Vector<StringName> extends_class; DataType base_type; @@ -198,6 +199,7 @@ public: tool = false; type = TYPE_CLASS; extends_used = false; + classname_used = false; end_line = -1; owner = NULL; } |