From dab73c701a9785be443977a613e57600d1e136c8 Mon Sep 17 00:00:00 2001 From: James Mintram Date: Sat, 26 Nov 2016 13:40:13 +0100 Subject: [PATCH] Compile error when duplicate key in dictionery literal #7034 --- modules/gdscript/gd_parser.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index 031f106df0b..4a36fbb4f1d 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -724,6 +724,7 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_ }; Node *key=NULL; + Set keys; DictExpect expecting=DICT_EXPECT_KEY; @@ -819,6 +820,16 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_ return NULL; expecting=DICT_EXPECT_COMMA; + if (key->type == GDParser::Node::TYPE_CONSTANT) { + Variant const& keyName = static_cast(key)->value; + + if (keys.has(keyName)) { + _set_error("Duplicate key found in Dictionary literal"); + return NULL; + } + keys.insert(keyName); + } + DictionaryNode::Pair pair; pair.key=key; pair.value=value;