From c7511de02e9123aadf4b81d3bef934fab27649e3 Mon Sep 17 00:00:00 2001 From: George Marques Date: Fri, 23 Apr 2021 15:42:33 -0300 Subject: 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. --- modules/gdscript/gdscript_compiler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules/gdscript/gdscript_compiler.cpp') diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index 7429e3cc0b..060ee7b058 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -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(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(subscript->index)->value; + name = subscript->index->reduced_value; named = true; } else { // Regular indexing. -- cgit v1.2.3 From 1e4ff2ede6b46368abb7dde1536618c190c779df Mon Sep 17 00:00:00 2001 From: George Marques Date: Fri, 23 Apr 2021 16:00:23 -0300 Subject: GDScript: Make sure Lua-style dicts use StringName as keys --- modules/gdscript/gdscript_compiler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules/gdscript/gdscript_compiler.cpp') diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index 060ee7b058..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(dn->elements[i].key)->name; + // Lua-style: key is an identifier interpreted as StringName. + StringName key = static_cast(dn->elements[i].key)->name; element = codegen.add_constant(key); break; } -- cgit v1.2.3