summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2022-12-17 11:30:54 +0100
committerGitHub <noreply@github.com>2022-12-17 11:30:54 +0100
commit791e742af7337bfe3107552612d19b6d53b3d8fc (patch)
tree5d4a0e7c4d5d0f6b0d32384ba00995c1c3d71edc
parentab354b8884bb3ae0a2802d8d8ce48a1d6feee4a0 (diff)
parent213c94b42fbb534bd33c9af144ecc3ecf93a2720 (diff)
Merge pull request #70180 from rune-scape/enum-value-regression
Fix enum value regression
-rw-r--r--modules/gdscript/gdscript_analyzer.cpp4
-rw-r--r--modules/gdscript/tests/scripts/analyzer/features/out_of_order.gd3
2 files changed, 5 insertions, 2 deletions
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp
index 30ac1f29b1..a443556fd5 100644
--- a/modules/gdscript/gdscript_analyzer.cpp
+++ b/modules/gdscript/gdscript_analyzer.cpp
@@ -996,7 +996,9 @@ void GDScriptAnalyzer::resolve_class_member(GDScriptParser::ClassNode *p_class,
check_class_member_name_conflict(p_class, member.enum_value.identifier->name, member.enum_value.parent_enum);
if (member.enum_value.index > 0) {
- member.enum_value.value = member.enum_value.parent_enum->values[member.enum_value.index - 1].value + 1;
+ const GDScriptParser::EnumNode::Value &prev_value = member.enum_value.parent_enum->values[member.enum_value.index - 1];
+ resolve_class_member(p_class, prev_value.identifier->name, member.enum_value.identifier);
+ member.enum_value.value = prev_value.value + 1;
} else {
member.enum_value.value = 0;
}
diff --git a/modules/gdscript/tests/scripts/analyzer/features/out_of_order.gd b/modules/gdscript/tests/scripts/analyzer/features/out_of_order.gd
index 069e54c528..11349cc916 100644
--- a/modules/gdscript/tests/scripts/analyzer/features/out_of_order.gd
+++ b/modules/gdscript/tests/scripts/analyzer/features/out_of_order.gd
@@ -42,7 +42,8 @@ const c2 := EV2
enum {
EV1 = 42,
- EV2 = EV3 + 1
+ UNUSED = EV3,
+ EV2
}
enum {