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_compiler.cpp | |
parent | db90ab86b94eb59eb296d574c279e40e57c2f99b (diff) | |
parent | 1e4ff2ede6b46368abb7dde1536618c190c779df (diff) | |
download | redot-engine-d1dc28e46c5ecb5cbbeeaccbca9940a070538a2a.tar.gz |
Merge pull request #48139 from vnen/gdscript-dict-keys
Fix mismatch between String and StringName in dictionary keys
Diffstat (limited to 'modules/gdscript/gdscript_compiler.cpp')
-rw-r--r-- | modules/gdscript/gdscript_compiler.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index 7429e3cc0b..9b718db7cf 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -427,8 +427,8 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code } break; case GDScriptParser::DictionaryNode::LUA_TABLE: - // Lua-style: key is an identifier interpreted as string. - String key = static_cast<const GDScriptParser::IdentifierNode *>(dn->elements[i].key)->name; + // Lua-style: key is an identifier interpreted as StringName. + StringName key = static_cast<const GDScriptParser::IdentifierNode *>(dn->elements[i].key)->name; element = codegen.add_constant(key); break; } @@ -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. |