Merge pull request #38041 from ThakeeNathees/class-name-check-enhance

GDScript class name existance check enhanced
This commit is contained in:
Rémi Verschelde 2020-04-21 16:19:53 +02:00 committed by GitHub
commit 4f03e302a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3673,6 +3673,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;
}