Ver Fonte

Prevents usage of return in main shader functions

Yuri Roubinsky há 5 anos atrás
pai
commit
2ce77e4b57
1 ficheiros alterados com 6 adições e 0 exclusões
  1. 6 0
      servers/rendering/shader_language.cpp

+ 6 - 0
servers/rendering/shader_language.cpp

@@ -5585,6 +5585,12 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const Map<StringName, Bui
 		} else if (tk.type == TK_CF_RETURN) {
 			//check return type
 			BlockNode *b = p_block;
+
+			if (b && b->parent_function && (b->parent_function->name == "vertex" || b->parent_function->name == "fragment" || b->parent_function->name == "light")) {
+				_set_error(vformat("Using 'return' in '%s' processor function results in undefined behavior!", b->parent_function->name));
+				return ERR_PARSE_ERROR;
+			}
+
 			while (b && !b->parent_function) {
 				b = b->parent_block;
 			}