GDScript class name existance check enhanced

(cherry picked from commit 62280c3d47)
This commit is contained in:
Thakee Nathees 2020-04-20 16:20:36 +05:30 committed by Rémi Verschelde
parent 12c776dba3
commit 95f6bdfa78
1 changed files with 6 additions and 0 deletions

View File

@ -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) + ")."); _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; 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; outer_class = outer_class->owner;
} }