From 4854e723be33cea4ebeb1aa697cb0a0d2aa1108f Mon Sep 17 00:00:00 2001 From: "ocean (they/them)" Date: Wed, 18 Jan 2023 09:12:27 -0500 Subject: [PATCH] Fix unnammed enum crash regression --- modules/gdscript/gdscript_analyzer.cpp | 2 +- .../tests/scripts/analyzer/features/enum_unnamed_depend.gd | 7 +++++++ .../scripts/analyzer/features/enum_unnamed_depend.out | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 modules/gdscript/tests/scripts/analyzer/features/enum_unnamed_depend.gd create mode 100644 modules/gdscript/tests/scripts/analyzer/features/enum_unnamed_depend.out diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index edd94da8242..e04a962dcb0 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -3171,7 +3171,7 @@ void GDScriptAnalyzer::reduce_identifier(GDScriptParser::IdentifierNode *p_ident for (int i = 0; i < current_enum->values.size(); i++) { const GDScriptParser::EnumNode::Value &element = current_enum->values[i]; if (element.identifier->name == p_identifier->name) { - StringName enum_name = current_enum->identifier->name ? current_enum->identifier->name : UNNAMED_ENUM; + StringName enum_name = current_enum->identifier ? current_enum->identifier->name : UNNAMED_ENUM; GDScriptParser::DataType type = make_enum_type(enum_name, parser->current_class->fqcn, false); if (element.parent_enum->identifier) { type.enum_type = element.parent_enum->identifier->name; diff --git a/modules/gdscript/tests/scripts/analyzer/features/enum_unnamed_depend.gd b/modules/gdscript/tests/scripts/analyzer/features/enum_unnamed_depend.gd new file mode 100644 index 00000000000..f351fc1f7bd --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/enum_unnamed_depend.gd @@ -0,0 +1,7 @@ +enum { + V1, + V2 = V1, +} + +func test(): + pass diff --git a/modules/gdscript/tests/scripts/analyzer/features/enum_unnamed_depend.out b/modules/gdscript/tests/scripts/analyzer/features/enum_unnamed_depend.out new file mode 100644 index 00000000000..d73c5eb7cde --- /dev/null +++ b/modules/gdscript/tests/scripts/analyzer/features/enum_unnamed_depend.out @@ -0,0 +1 @@ +GDTEST_OK