diff options
| author | Karroffel | 2017-08-22 14:54:52 +0200 |
|---|---|---|
| committer | Karroffel | 2017-08-22 17:45:05 +0200 |
| commit | 57654d4b950d2bbb9e3cb28721aeb3f4499ea2f9 (patch) | |
| tree | aee0a933dac9f9d9ff1bd80d12a7b8fd1d07a208 /modules/gdscript/gd_parser.cpp | |
| parent | 19e12424fc1786e24b372c2b62d9fbf262bfc227 (diff) | |
| download | godot-57654d4b950d2bbb9e3cb28721aeb3f4499ea2f9.tar.gz godot-57654d4b950d2bbb9e3cb28721aeb3f4499ea2f9.tar.zst godot-57654d4b950d2bbb9e3cb28721aeb3f4499ea2f9.zip | |
Diffstat (limited to 'modules/gdscript/gd_parser.cpp')
| -rw-r--r-- | modules/gdscript/gd_parser.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gd_parser.cpp index 7d3857266..b349b6b9a 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gd_parser.cpp @@ -1894,7 +1894,26 @@ GDParser::PatternNode *GDParser::_parse_pattern(bool p_static) { return NULL; } - if (value->type != Node::TYPE_IDENTIFIER && value->type != Node::TYPE_CONSTANT) { + if (value->type == Node::TYPE_OPERATOR) { + // Maybe it's SomeEnum.VALUE + Node *current_value = value; + + while (current_value->type == Node::TYPE_OPERATOR) { + OperatorNode *op_node = static_cast<OperatorNode *>(current_value); + + if (op_node->op != OperatorNode::OP_INDEX_NAMED) { + _set_error("Invalid operator in pattern. Only index (`A.B`) is allowed"); + return NULL; + } + current_value = op_node->arguments[0]; + } + + if (current_value->type != Node::TYPE_IDENTIFIER) { + _set_error("Only constant expression or variables allowed in a pattern"); + return NULL; + } + + } else if (value->type != Node::TYPE_IDENTIFIER && value->type != Node::TYPE_CONSTANT) { _set_error("Only constant expressions or variables allowed in a pattern"); return NULL; } |
