diff options
author | DaividFrank <DaividSavernin@outlook.com> | 2020-01-21 21:57:22 +0200 |
---|---|---|
committer | DaividFrank <DaividSavernin@outlook.com> | 2020-01-22 19:00:54 +0200 |
commit | badabdf8b993f7fbc1d9d824b3bf592651f0dee3 (patch) | |
tree | e71a6f6cc7b99d8be75350c6acd7f90e717a8666 /modules | |
parent | d4a222cd9d849a63f0535f70cbf78700bc5c815b (diff) |
GDScript: Added checks in assign operations to disable re-assigning 'self'
Diffstat (limited to 'modules')
-rw-r--r-- | modules/gdscript/gdscript_parser.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 5c2e7137bf..c123d5ab08 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -1868,6 +1868,10 @@ GDScriptParser::Node *GDScriptParser::_reduce_expression(Node *p_node, bool p_to _set_error("Can't assign to constant", tokenizer->get_token_line() - 1); error_line = op->line; return op; + } else if (op->arguments[0]->type == Node::TYPE_SELF) { + _set_error("Can't assign to self.", op->line); + error_line = op->line; + return op; } if (op->arguments[0]->type == Node::TYPE_OPERATOR) { @@ -6290,6 +6294,7 @@ GDScriptParser::DataType GDScriptParser::_reduce_node_type(Node *p_node) { node_type.has_type = true; node_type.kind = DataType::CLASS; node_type.class_type = current_class; + node_type.is_constant = true; } break; case Node::TYPE_IDENTIFIER: { IdentifierNode *id = static_cast<IdentifierNode *>(p_node); |