summaryrefslogtreecommitdiff
path: root/modules/gdscript
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-09-19 20:05:41 +0200
committerGitHub <noreply@github.com>2019-09-19 20:05:41 +0200
commitb5f14cc6f7e4f5ad49119e31fb26dcf5277af1de (patch)
treedb65115798deaf98a3b0cfeca6a303db8fa8ca84 /modules/gdscript
parent1e73a44e241774d1ea84a8976f0963ae7df71cf9 (diff)
parent8f5ffeeacc3ee5537f32a931f2d1ad566747ad9f (diff)
Merge pull request #31934 from mitchcurtis/28187
Produce an error when a class has the same name as a Singleton
Diffstat (limited to 'modules/gdscript')
-rw-r--r--modules/gdscript/gdscript_parser.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp
index 0253e48f9d..9c3fc9a351 100644
--- a/modules/gdscript/gdscript_parser.cpp
+++ b/modules/gdscript/gdscript_parser.cpp
@@ -3554,6 +3554,15 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
return;
}
+ if (p_class->classname_used && ProjectSettings::get_singleton()->has_setting("autoload/" + p_class->name)) {
+ const String autoload_path = ProjectSettings::get_singleton()->get_setting("autoload/" + p_class->name);
+ if (autoload_path.begins_with("*")) {
+ // It's a singleton, and not just a regular AutoLoad script.
+ _set_error("The class \"" + p_class->name + "\" conflicts with the AutoLoad singleton of the same name, and is therefore redundant. Remove the class_name declaration to fix this error.");
+ }
+ return;
+ }
+
tokenizer->advance(2);
if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) {