Allow using empty statements in the shader, added formatting warning

This commit is contained in:
Yuri Roubinsky
2021-11-30 23:28:35 +03:00
parent e223a9c129
commit 5ba93619fa
7 changed files with 31 additions and 3 deletions

View File

@ -5208,9 +5208,21 @@ ShaderLanguage::Node *ShaderLanguage::_parse_expression(BlockNode *p_block, cons
expression.push_back(e);
continue;
} else {
_set_error("Expected expression, found: " + get_token_text(tk));
return nullptr;
//nothing
if (tk.type != TK_SEMICOLON) {
_set_error("Expected expression, found: " + get_token_text(tk));
return nullptr;
} else {
#if DEBUG_ENABLED
if (check_warnings && HAS_WARNING(ShaderWarning::FORMATTING_ERROR_FLAG)) {
_add_line_warning(ShaderWarning::FORMATTING_ERROR, "Empty statement. Remove ';' to fix this warning.");
}
#endif // DEBUG_ENABLED
_set_tkpos(prepos);
OperatorNode *func = alloc_node<OperatorNode>();
func->op = OP_EMPTY;
expr = func;
}
}
ERR_FAIL_COND_V(!expr, nullptr);