You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-06 12:20:30 +00:00
Fix premature declaration of shader variables created with assignment
This commit is contained in:
@@ -3209,8 +3209,6 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
|
|||||||
var.precision = precision;
|
var.precision = precision;
|
||||||
var.line = tk_line;
|
var.line = tk_line;
|
||||||
|
|
||||||
p_block->variables[name] = var;
|
|
||||||
|
|
||||||
VariableDeclarationNode::Declaration decl;
|
VariableDeclarationNode::Declaration decl;
|
||||||
|
|
||||||
decl.name = name;
|
decl.name = name;
|
||||||
@@ -3219,7 +3217,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
|
|||||||
tk = _get_token();
|
tk = _get_token();
|
||||||
|
|
||||||
if (tk.type == TK_OP_ASSIGN) {
|
if (tk.type == TK_OP_ASSIGN) {
|
||||||
//variable creted with assignment! must parse an expression
|
//variable created with assignment! must parse an expression
|
||||||
Node *n = _parse_and_reduce_expression(p_block, p_builtin_types);
|
Node *n = _parse_and_reduce_expression(p_block, p_builtin_types);
|
||||||
if (!n)
|
if (!n)
|
||||||
return ERR_PARSE_ERROR;
|
return ERR_PARSE_ERROR;
|
||||||
@@ -3233,6 +3231,8 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
|
|||||||
tk = _get_token();
|
tk = _get_token();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p_block->variables[name] = var;
|
||||||
|
|
||||||
vardecl->declarations.push_back(decl);
|
vardecl->declarations.push_back(decl);
|
||||||
|
|
||||||
if (tk.type == TK_COMMA) {
|
if (tk.type == TK_COMMA) {
|
||||||
|
|||||||
Reference in New Issue
Block a user