Merge pull request #47492 from vnen/gdscript-typed-arrays

GDScript: Fix array type check on constants
This commit is contained in:
Rémi Verschelde 2021-03-30 14:37:42 +02:00 committed by GitHub
commit 7c14e987b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -644,11 +644,11 @@ void GDScriptAnalyzer::resolve_class_interface(GDScriptParser::ClassNode *p_clas
GDScriptParser::DataType datatype = member.constant->get_datatype(); GDScriptParser::DataType datatype = member.constant->get_datatype();
if (member.constant->initializer) { if (member.constant->initializer) {
if (member.constant->initializer->type == GDScriptParser::Node::ARRAY) { if (member.constant->initializer->type == GDScriptParser::Node::ARRAY) {
GDScriptParser::ArrayNode *array = static_cast<GDScriptParser::ArrayNode *>(member.variable->initializer); GDScriptParser::ArrayNode *array = static_cast<GDScriptParser::ArrayNode *>(member.constant->initializer);
const_fold_array(array); const_fold_array(array);
// Can only infer typed array if it has elements. // Can only infer typed array if it has elements.
if (array->elements.size() > 0 || (member.variable->datatype_specifier != nullptr && specified_type.has_container_element_type())) { if (array->elements.size() > 0 || (member.constant->datatype_specifier != nullptr && specified_type.has_container_element_type())) {
update_array_literal_element_type(specified_type, array); update_array_literal_element_type(specified_type, array);
} }
} else if (member.constant->initializer->type == GDScriptParser::Node::DICTIONARY) { } else if (member.constant->initializer->type == GDScriptParser::Node::DICTIONARY) {