diff options
author | Yuri Roubinsky <chaosus89@gmail.com> | 2021-12-01 18:08:14 +0300 |
---|---|---|
committer | Yuri Roubinsky <chaosus89@gmail.com> | 2021-12-01 18:11:45 +0300 |
commit | 5ee73dc5a6302c3ed6a770bffbb11d5a8dd3122b (patch) | |
tree | f0cfaa1e26e3927781cede074ef9140c59b43834 /servers/rendering | |
parent | fe6ff611302d80ae68f86eb57c1b7d3f6bf29ad0 (diff) |
Fix shader crash when using existed constant name for struct
Diffstat (limited to 'servers/rendering')
-rw-r--r-- | servers/rendering/shader_language.cpp | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/servers/rendering/shader_language.cpp b/servers/rendering/shader_language.cpp index 0197047b04..052b1d6d9f 100644 --- a/servers/rendering/shader_language.cpp +++ b/servers/rendering/shader_language.cpp @@ -7502,7 +7502,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct tk = _get_token(); if (tk.type == TK_IDENTIFIER) { st.name = tk.text; - if (shader->structs.has(st.name)) { + if (shader->constants.has(st.name) || shader->structs.has(st.name)) { _set_error("Redefinition of '" + String(st.name) + "'"); return ERR_PARSE_ERROR; } @@ -8212,12 +8212,7 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct return ERR_PARSE_ERROR; } - if (_find_identifier(nullptr, false, constants, name)) { - _set_error("Redefinition of '" + String(name) + "'"); - return ERR_PARSE_ERROR; - } - - if (has_builtin(p_functions, name)) { + if (shader->structs.has(name) || _find_identifier(nullptr, false, constants, name) || has_builtin(p_functions, name)) { _set_error("Redefinition of '" + String(name) + "'"); return ERR_PARSE_ERROR; } |