Merge pull request #31345 from Chaosus/shader_const_strict

Force user to initialize local shader constants
This commit is contained in:
Rémi Verschelde 2019-08-13 12:47:06 +02:00 committed by GitHub
commit 0a10a93fb0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4022,6 +4022,10 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
_set_error("Expected array initialization");
return ERR_PARSE_ERROR;
}
if (is_const) {
_set_error("Expected initialization of constant");
return ERR_PARSE_ERROR;
}
}
node->declarations.push_back(decl);
@ -4051,6 +4055,11 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
tk = _get_token();
node->declarations.push_back(decl);
} else {
if (is_const) {
_set_error("Expected initialization of constant");
return ERR_PARSE_ERROR;
}
VariableDeclarationNode *node = alloc_node<VariableDeclarationNode>();
node->datatype = type;
node->precision = precision;