summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2022-12-11 15:18:18 +0100
committerRémi Verschelde <rverschelde@gmail.com>2022-12-11 15:18:18 +0100
commit185219de4ac108009c9fe14d36f7c061e63a9660 (patch)
tree446748588b3ffbc02605a1bf31e8d83c42cc1fef /modules
parentc00b9e5b34e0c91e85f549f340510b019bee3290 (diff)
parent98e1a2031dc302ec67709d568d2e98e638f21145 (diff)
Merge pull request #69907 from rune-scape/sub-script
Fix subscript of preloaded script
Diffstat (limited to 'modules')
-rw-r--r--modules/gdscript/gdscript_analyzer.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp
index 2892ae3f4e..103085bc3d 100644
--- a/modules/gdscript/gdscript_analyzer.cpp
+++ b/modules/gdscript/gdscript_analyzer.cpp
@@ -3345,7 +3345,10 @@ void GDScriptAnalyzer::reduce_subscript(GDScriptParser::SubscriptNode *p_subscri
if (p_subscript->attribute == nullptr) {
return;
}
- if (p_subscript->base->is_constant) {
+
+ GDScriptParser::DataType base_type = p_subscript->base->get_datatype();
+ // If base is a class metatype, use the analyzer instead.
+ if (p_subscript->base->is_constant && !(base_type.is_meta_type && base_type.kind == GDScriptParser::DataType::CLASS)) {
// Just try to get it.
bool valid = false;
Variant value = p_subscript->base->reduced_value.get_named(p_subscript->attribute->name, valid);
@@ -3369,8 +3372,6 @@ void GDScriptAnalyzer::reduce_subscript(GDScriptParser::SubscriptNode *p_subscri
result_type = type_from_variant(value, p_subscript);
}
} else {
- GDScriptParser::DataType base_type = p_subscript->base->get_datatype();
-
if (base_type.is_variant() || !base_type.is_hard_type()) {
result_type.kind = GDScriptParser::DataType::VARIANT;
mark_node_unsafe(p_subscript);