summaryrefslogtreecommitdiff
path: root/modules/gdscript
diff options
context:
space:
mode:
authorDmitrii Maganov <vonagam@gmail.com>2023-02-02 02:14:25 +0200
committerDmitrii Maganov <vonagam@gmail.com>2023-02-02 02:15:26 +0200
commit7b04e3865a48e216cceca5d7d56ec76b65413f4a (patch)
tree2fe2bde3c3a9d2916c36a0784cf555960e30a58d /modules/gdscript
parent0a9e6e478e3183d7bf3c5cb895c706bc6275d3ea (diff)
GDScript: Fix getting reduced value of incomplete subscript
Diffstat (limited to 'modules/gdscript')
-rw-r--r--modules/gdscript/gdscript_analyzer.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp
index 1c2b743909..cdb4f29854 100644
--- a/modules/gdscript/gdscript_analyzer.cpp
+++ b/modules/gdscript/gdscript_analyzer.cpp
@@ -4037,6 +4037,10 @@ void GDScriptAnalyzer::reduce_unary_op(GDScriptParser::UnaryOpNode *p_unary_op)
Variant GDScriptAnalyzer::make_expression_reduced_value(GDScriptParser::ExpressionNode *p_expression, bool &is_reduced) {
Variant value;
+ if (p_expression == nullptr) {
+ return value;
+ }
+
if (p_expression->is_constant) {
is_reduced = true;
value = p_expression->reduced_value;
@@ -4101,6 +4105,10 @@ Variant GDScriptAnalyzer::make_dictionary_reduced_value(GDScriptParser::Dictiona
}
Variant GDScriptAnalyzer::make_subscript_reduced_value(GDScriptParser::SubscriptNode *p_subscript, bool &is_reduced) {
+ if (p_subscript->base == nullptr || p_subscript->index == nullptr) {
+ return Variant();
+ }
+
bool is_base_value_reduced = false;
Variant base_value = make_expression_reduced_value(p_subscript->base, is_base_value_reduced);
if (!is_base_value_reduced) {