You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-10 13:00:37 +00:00
Disallow assignment to constants and expressions
Fixes #6221, fixes #6824
This commit is contained in:
@@ -1478,6 +1478,15 @@ GDParser::Node* GDParser::_reduce_expression(Node *p_node,bool p_to_const) {
|
|||||||
return op;
|
return op;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (op->arguments[0]->type==Node::TYPE_OPERATOR) {
|
||||||
|
OperatorNode *on = static_cast<OperatorNode*>(op->arguments[0]);
|
||||||
|
if (on->op != OperatorNode::OP_INDEX && on->op != OperatorNode::OP_INDEX_NAMED) {
|
||||||
|
_set_error("Can't assign to an expression",tokenizer->get_token_line()-1);
|
||||||
|
error_line=op->line;
|
||||||
|
return op;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
default: { break; }
|
default: { break; }
|
||||||
}
|
}
|
||||||
@@ -2014,7 +2023,7 @@ void GDParser::_parse_block(BlockNode *p_block,bool p_static) {
|
|||||||
} break;
|
} break;
|
||||||
default: {
|
default: {
|
||||||
|
|
||||||
Node *expression = _parse_and_reduce_expression(p_block,p_static,false,true);
|
Node *expression = _parse_and_reduce_expression(p_block,p_static,true,true);
|
||||||
if (!expression) {
|
if (!expression) {
|
||||||
if (_recover_from_completion()) {
|
if (_recover_from_completion()) {
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user