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 ++-- modules/gdscript/gdscript_parser.cpp | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) 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; } diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index ca8bb8fcae..d910137510 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -2440,6 +2440,8 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_dictionary(ExpressionNode push_error(R"(Expected "=" after dictionary key.)"); } } + key->is_constant = true; + key->reduced_value = static_cast(key)->name; break; case DictionaryNode::PYTHON_DICT: if (!match(GDScriptTokenizer::Token::COLON)) { -- cgit v1.2.3