GDScript: Fix resolution of dictionary keys

There was a mixup between String and StringName keys. Now they're
clearly separated. This also means you have to consider which type
you're using for the dictionary keys and how you are accessing them.
This commit is contained in:
George Marques 2021-04-23 15:42:33 -03:00
parent 77a876c6e1
commit c7511de02e
No known key found for this signature in database
GPG key ID: 046BD46A3201E43D
2 changed files with 6 additions and 22 deletions

View file

@ -680,9 +680,9 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
name = subscript->attribute->name;
named = true;
} else {
if (subscript->index->type == GDScriptParser::Node::LITERAL && static_cast<const GDScriptParser::LiteralNode *>(subscript->index)->value.get_type() == Variant::STRING) {
if (subscript->index->is_constant && subscript->index->reduced_value.get_type() == Variant::STRING_NAME) {
// Also, somehow, named (speed up anyway).
name = static_cast<const GDScriptParser::LiteralNode *>(subscript->index)->value;
name = subscript->index->reduced_value;
named = true;
} else {
// Regular indexing.