|
@@ -4863,6 +4863,20 @@ void GDScriptParser::_parse_class(ClassNode *p_class) {
|
|
|
|
|
|
StringName const_id = tokenizer->get_token_literal();
|
|
|
|
|
|
+ if (current_class->constant_expressions.has(const_id)) {
|
|
|
+ _set_error("A constant named '" + String(const_id) + "' already exists in this class (at line: " +
|
|
|
+ itos(current_class->constant_expressions[const_id].expression->line) + ").");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < current_class->variables.size(); i++) {
|
|
|
+ if (current_class->variables[i].identifier == const_id) {
|
|
|
+ _set_error("A variable named '" + String(const_id) + "' already exists in this class (at line: " +
|
|
|
+ itos(current_class->variables[i].line) + ").");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
tokenizer->advance();
|
|
|
|
|
|
if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_ASSIGN) {
|
|
@@ -7216,6 +7230,12 @@ void GDScriptParser::_check_class_level_types(ClassNode *p_class) {
|
|
|
expr.is_constant = true;
|
|
|
c.type = expr;
|
|
|
c.expression->set_datatype(expr);
|
|
|
+
|
|
|
+ DataType tmp;
|
|
|
+ if (_get_member_type(p_class->base_type, E->key(), tmp)) {
|
|
|
+ _set_error("Member '" + String(E->key()) + "' already exists in parent class.", c.expression->line);
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// Function declarations
|