diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-09 23:10:37 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-01-09 23:10:37 +0100 |
commit | 509da8620537f150eb6f2266ddf330ee2ffbfea4 (patch) | |
tree | c6e95a609beab64bee4d928a1ab9b20181cda007 /modules/gdscript/gdscript_parser.cpp | |
parent | 4d4fcd0a6f9ae92c93be7a0e8eab9a22aaea31d3 (diff) | |
parent | 366ec895b1b73e3d509fbc591a6289c0d03774aa (diff) | |
download | redot-engine-509da8620537f150eb6f2266ddf330ee2ffbfea4.tar.gz |
Merge pull request #69590 from anvilfolk/enums
GDScript enum fixes & refactor
Diffstat (limited to 'modules/gdscript/gdscript_parser.cpp')
-rw-r--r-- | modules/gdscript/gdscript_parser.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index add8a02e55..a6b8537074 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -1299,16 +1299,18 @@ GDScriptParser::EnumNode *GDScriptParser::parse_enum() { EnumNode::Value item; GDScriptParser::IdentifierNode *identifier = parse_identifier(); #ifdef DEBUG_ENABLED - for (MethodInfo &info : gdscript_funcs) { - if (info.name == identifier->name) { + if (!named) { // Named enum identifiers do not shadow anything since you can only access them with NamedEnum.ENUM_VALUE + for (MethodInfo &info : gdscript_funcs) { + if (info.name == identifier->name) { + push_warning(identifier, GDScriptWarning::SHADOWED_GLOBAL_IDENTIFIER, "enum member", identifier->name, "built-in function"); + } + } + if (Variant::has_utility_function(identifier->name)) { push_warning(identifier, GDScriptWarning::SHADOWED_GLOBAL_IDENTIFIER, "enum member", identifier->name, "built-in function"); + } else if (ClassDB::class_exists(identifier->name)) { + push_warning(identifier, GDScriptWarning::SHADOWED_GLOBAL_IDENTIFIER, "enum member", identifier->name, "global class"); } } - if (Variant::has_utility_function(identifier->name)) { - push_warning(identifier, GDScriptWarning::SHADOWED_GLOBAL_IDENTIFIER, "enum member", identifier->name, "built-in function"); - } else if (ClassDB::class_exists(identifier->name)) { - push_warning(identifier, GDScriptWarning::SHADOWED_GLOBAL_IDENTIFIER, "enum member", identifier->name, "global class"); - } #endif item.identifier = identifier; item.parent_enum = enum_node; @@ -4092,8 +4094,11 @@ String GDScriptParser::DataType::to_string() const { } return native_type.operator String(); } - case ENUM: - return enum_type.operator String() + " (enum)"; + case ENUM: { + // native_type contains either the native class defining the enum + // or the fully qualified class name of the script defining the enum + return String(native_type).get_file(); // Remove path, keep filename + } case RESOLVING: case UNRESOLVED: return "<unresolved type>"; |