diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-04-24 19:46:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-24 19:46:59 +0200 |
commit | d1dc28e46c5ecb5cbbeeaccbca9940a070538a2a (patch) | |
tree | 13bf7616bec827cbca07fd546d78c4f7e8628eb7 /modules/gdscript/gdscript_analyzer.cpp | |
parent | db90ab86b94eb59eb296d574c279e40e57c2f99b (diff) | |
parent | 1e4ff2ede6b46368abb7dde1536618c190c779df (diff) |
Merge pull request #48139 from vnen/gdscript-dict-keys
Fix mismatch between String and StringName in dictionary keys
Diffstat (limited to 'modules/gdscript/gdscript_analyzer.cpp')
-rw-r--r-- | modules/gdscript/gdscript_analyzer.cpp | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/modules/gdscript/gdscript_analyzer.cpp b/modules/gdscript/gdscript_analyzer.cpp index bdca64c146..5da2bb5cc1 100644 --- a/modules/gdscript/gdscript_analyzer.cpp +++ b/modules/gdscript/gdscript_analyzer.cpp @@ -2621,25 +2621,6 @@ void GDScriptAnalyzer::reduce_subscript(GDScriptParser::SubscriptNode *p_subscri GDScriptParser::DataType result_type; - // Reduce index first. If it's a constant StringName, use attribute instead. - if (!p_subscript->is_attribute) { - if (p_subscript->index == nullptr) { - return; - } - reduce_expression(p_subscript->index); - - if (p_subscript->index->is_constant && p_subscript->index->reduced_value.get_type() == Variant::STRING_NAME) { - GDScriptParser::IdentifierNode *attribute = parser->alloc_node<GDScriptParser::IdentifierNode>(); - // Copy location for better error message. - attribute->start_line = p_subscript->index->start_line; - attribute->end_line = p_subscript->index->end_line; - attribute->leftmost_column = p_subscript->index->leftmost_column; - attribute->rightmost_column = p_subscript->index->rightmost_column; - p_subscript->is_attribute = true; - p_subscript->attribute = attribute; - } - } - if (p_subscript->is_attribute) { if (p_subscript->attribute == nullptr) { return; @@ -2682,7 +2663,10 @@ void GDScriptAnalyzer::reduce_subscript(GDScriptParser::SubscriptNode *p_subscri } } } else { - // Index was already reduced before. + if (p_subscript->index == nullptr) { + return; + } + reduce_expression(p_subscript->index); if (p_subscript->base->is_constant && p_subscript->index->is_constant) { // Just try to get it. |