Fix middle expression of for loop to accept not only operators

This commit is contained in:
Chaosus 2024-08-15 10:29:19 +03:00
parent 33c30b9e63
commit 3272f00525

View File

@ -8061,7 +8061,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun
if (!expr) { if (!expr) {
return ERR_PARSE_ERROR; return ERR_PARSE_ERROR;
} }
is_condition = expr->type == Node::NODE_TYPE_OPERATOR && expr->get_datatype() == TYPE_BOOL; is_condition = expr->get_datatype() == TYPE_BOOL;
if (expr->type == Node::NODE_TYPE_OPERATOR) { if (expr->type == Node::NODE_TYPE_OPERATOR) {
OperatorNode *op = static_cast<OperatorNode *>(expr); OperatorNode *op = static_cast<OperatorNode *>(expr);
@ -8077,7 +8077,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun
if (p_block->block_type == BlockNode::BLOCK_TYPE_FOR_CONDITION) { if (p_block->block_type == BlockNode::BLOCK_TYPE_FOR_CONDITION) {
if (tk.type == TK_COMMA) { if (tk.type == TK_COMMA) {
if (!is_condition) { if (!is_condition) {
_set_error(RTR("The middle expression is expected to be a boolean operator.")); _set_error(RTR("The middle expression is expected to have a boolean data type."));
return ERR_PARSE_ERROR; return ERR_PARSE_ERROR;
} }
continue; continue;
@ -8106,7 +8106,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun
return ERR_PARSE_ERROR; return ERR_PARSE_ERROR;
} }
if (p_block->block_type == BlockNode::BLOCK_TYPE_FOR_CONDITION && !is_condition) { if (p_block->block_type == BlockNode::BLOCK_TYPE_FOR_CONDITION && !is_condition) {
_set_error(RTR("The middle expression is expected to be a boolean operator.")); _set_error(RTR("The middle expression is expected to have a boolean data type."));
return ERR_PARSE_ERROR; return ERR_PARSE_ERROR;
} }
} }