Compile error when duplicate key in dictionery literal #7034
This commit is contained in:
parent
8d3aedeefd
commit
dab73c701a
1 changed files with 11 additions and 0 deletions
|
@ -724,6 +724,7 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
|
||||||
};
|
};
|
||||||
|
|
||||||
Node *key=NULL;
|
Node *key=NULL;
|
||||||
|
Set<Variant> keys;
|
||||||
|
|
||||||
DictExpect expecting=DICT_EXPECT_KEY;
|
DictExpect expecting=DICT_EXPECT_KEY;
|
||||||
|
|
||||||
|
@ -819,6 +820,16 @@ GDParser::Node* GDParser::_parse_expression(Node *p_parent,bool p_static,bool p_
|
||||||
return NULL;
|
return NULL;
|
||||||
expecting=DICT_EXPECT_COMMA;
|
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;
|
DictionaryNode::Pair pair;
|
||||||
pair.key=key;
|
pair.key=key;
|
||||||
pair.value=value;
|
pair.value=value;
|
||||||
|
|
Loading…
Reference in a new issue