Compile error when duplicate key in dictionery literal #7034

This commit is contained in:
James Mintram 2016-11-26 13:40:13 +01:00 committed by Rémi Verschelde
parent 8d3aedeefd
commit dab73c701a

View file

@ -724,6 +724,7 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
};
Node *key=NULL;
Set<Variant> 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<const GDParser::ConstantNode*>(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;