Prevent shader crash if multiple variables has been declared in 'for'
This commit is contained in:
parent
0ecca1abd0
commit
aa33db056a
2 changed files with 6 additions and 0 deletions
|
@ -5070,6 +5070,10 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
|
|||
p_block->variables[name] = var;
|
||||
|
||||
if (tk.type == TK_COMMA) {
|
||||
if (p_block->block_type == BlockNode::BLOCK_TYPE_FOR) {
|
||||
_set_error("Multiple declarations in 'for' loop are not implemented yet.");
|
||||
return ERR_PARSE_ERROR;
|
||||
}
|
||||
tk = _get_token();
|
||||
//another variable
|
||||
} else if (tk.type == TK_SEMICOLON) {
|
||||
|
@ -5394,6 +5398,7 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
|
|||
cf->flow_op = FLOW_OP_FOR;
|
||||
|
||||
BlockNode *init_block = alloc_node<BlockNode>();
|
||||
init_block->block_type = BlockNode::BLOCK_TYPE_FOR;
|
||||
init_block->parent_block = p_block;
|
||||
init_block->single_statement = true;
|
||||
cf->blocks.push_back(init_block);
|
||||
|
|
|
@ -487,6 +487,7 @@ public:
|
|||
|
||||
enum BlockType {
|
||||
BLOCK_TYPE_STANDART,
|
||||
BLOCK_TYPE_FOR,
|
||||
BLOCK_TYPE_SWITCH,
|
||||
BLOCK_TYPE_CASE,
|
||||
BLOCK_TYPE_DEFAULT,
|
||||
|
|
Loading…
Reference in a new issue