GDScript: Allow string keys on Lua-style dictionaries

Which is useful when the key isn't a valid identifier, such as keys with
spaces or numeric keys.
This commit is contained in:
George Marques
2021-09-15 09:56:24 -03:00
parent 32f8f74d83
commit 5d31ce4b16
10 changed files with 48 additions and 4 deletions

View File

@ -440,7 +440,7 @@ GDScriptCodeGenerator::Address GDScriptCompiler::_parse_expression(CodeGen &code
break;
case GDScriptParser::DictionaryNode::LUA_TABLE:
// Lua-style: key is an identifier interpreted as StringName.
StringName key = static_cast<const GDScriptParser::IdentifierNode *>(dn->elements[i].key)->name;
StringName key = dn->elements[i].key->reduced_value.operator StringName();
element = codegen.add_constant(key);
break;
}