You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Allow default case at the top of a switch scope in shaders
Revert "Removed translations of unused error message" This reverts commit 6dbc75e000375196eb0176e65eb41935f71fc4fe. Variable name change Detecting multiple default cases in shaders Removed translations of unused error message Allowing default case at top of scope in switch statement in shaders
This commit is contained in:
@@ -8460,9 +8460,11 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun
|
|||||||
|
|
||||||
pos = _get_tkpos();
|
pos = _get_tkpos();
|
||||||
tk = _get_token();
|
tk = _get_token();
|
||||||
TokenType prev_type;
|
bool has_default = false;
|
||||||
if (tk.type == TK_CF_CASE || tk.type == TK_CF_DEFAULT) {
|
if (tk.type == TK_CF_CASE || tk.type == TK_CF_DEFAULT) {
|
||||||
prev_type = tk.type;
|
if (tk.type == TK_CF_DEFAULT) {
|
||||||
|
has_default = true;
|
||||||
|
}
|
||||||
_set_tkpos(pos);
|
_set_tkpos(pos);
|
||||||
} else {
|
} else {
|
||||||
_set_expected_error("case", "default");
|
_set_expected_error("case", "default");
|
||||||
@@ -8476,17 +8478,15 @@ Error ShaderLanguage::_parse_block(BlockNode *p_block, const FunctionInfo &p_fun
|
|||||||
}
|
}
|
||||||
pos = _get_tkpos();
|
pos = _get_tkpos();
|
||||||
tk = _get_token();
|
tk = _get_token();
|
||||||
if (tk.type == TK_CF_CASE || tk.type == TK_CF_DEFAULT) {
|
if (tk.type == TK_CF_CASE) {
|
||||||
if (prev_type == TK_CF_DEFAULT) {
|
_set_tkpos(pos);
|
||||||
if (tk.type == TK_CF_CASE) {
|
continue;
|
||||||
_set_error(RTR("Cases must be defined before default case."));
|
} else if (tk.type == TK_CF_DEFAULT) {
|
||||||
return ERR_PARSE_ERROR;
|
if (has_default) {
|
||||||
} else if (prev_type == TK_CF_DEFAULT) {
|
_set_error(RTR("Default case must be defined only once."));
|
||||||
_set_error(RTR("Default case must be defined only once."));
|
return ERR_PARSE_ERROR;
|
||||||
return ERR_PARSE_ERROR;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
prev_type = tk.type;
|
has_default = true;
|
||||||
_set_tkpos(pos);
|
_set_tkpos(pos);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user