From 95f6bdfa783234d62404030e00650341ec689f29 Mon Sep 17 00:00:00 2001 From: Thakee Nathees Date: Mon, 20 Apr 2020 16:20:36 +0530 Subject: [PATCH] GDScript class name existance check enhanced (cherry picked from commit 62280c3d47bf4cda3775013b1676a2b651e18756) --- modules/gdscript/gdscript_parser.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 3565ce148a7..e9c9c66d87a 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -3674,6 +3674,12 @@ void GDScriptParser::_parse_class(ClassNode *p_class) { _set_error("A constant named \"" + String(name) + "\" already exists in the outer class scope (at line" + itos(outer_class->constant_expressions[name].expression->line) + ")."); return; } + for (int i = 0; i < outer_class->variables.size(); i++) { + if (outer_class->variables[i].identifier == name) { + _set_error("A variable named \"" + String(name) + "\" already exists in the outer class scope (at line " + itos(outer_class->variables[i].line) + ")."); + return; + } + } outer_class = outer_class->owner; }