You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Compile error when duplicate key in dictionery literal #7034
This commit is contained in:
committed by
Rémi Verschelde
parent
8d3aedeefd
commit
dab73c701a
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user