Merge pull request #55201 from Scony/fix-unreachable-code-false-positive
This commit is contained in:
commit
e22255edaf
@ -1808,7 +1808,6 @@ GDScriptParser::MatchNode *GDScriptParser::parse_match() {
|
|||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
bool all_have_return = true;
|
bool all_have_return = true;
|
||||||
bool have_wildcard = false;
|
bool have_wildcard = false;
|
||||||
bool wildcard_has_return = false;
|
|
||||||
bool have_wildcard_without_continue = false;
|
bool have_wildcard_without_continue = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1826,9 +1825,6 @@ GDScriptParser::MatchNode *GDScriptParser::parse_match() {
|
|||||||
|
|
||||||
if (branch->has_wildcard) {
|
if (branch->has_wildcard) {
|
||||||
have_wildcard = true;
|
have_wildcard = true;
|
||||||
if (branch->block->has_return) {
|
|
||||||
wildcard_has_return = true;
|
|
||||||
}
|
|
||||||
if (!branch->block->has_continue) {
|
if (!branch->block->has_continue) {
|
||||||
have_wildcard_without_continue = true;
|
have_wildcard_without_continue = true;
|
||||||
}
|
}
|
||||||
@ -1843,7 +1839,7 @@ GDScriptParser::MatchNode *GDScriptParser::parse_match() {
|
|||||||
consume(GDScriptTokenizer::Token::DEDENT, R"(Expected an indented block after "match" statement.)");
|
consume(GDScriptTokenizer::Token::DEDENT, R"(Expected an indented block after "match" statement.)");
|
||||||
|
|
||||||
#ifdef DEBUG_ENABLED
|
#ifdef DEBUG_ENABLED
|
||||||
if (wildcard_has_return || (all_have_return && have_wildcard)) {
|
if (all_have_return && have_wildcard) {
|
||||||
current_suite->has_return = true;
|
current_suite->has_return = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -0,0 +1,16 @@
|
|||||||
|
func test():
|
||||||
|
var foo := "bar"
|
||||||
|
match foo:
|
||||||
|
"baz":
|
||||||
|
return
|
||||||
|
_:
|
||||||
|
pass
|
||||||
|
match foo:
|
||||||
|
"baz":
|
||||||
|
return
|
||||||
|
match foo:
|
||||||
|
"bar":
|
||||||
|
pass
|
||||||
|
_:
|
||||||
|
return
|
||||||
|
print("reached")
|
@ -0,0 +1,2 @@
|
|||||||
|
GDTEST_OK
|
||||||
|
reached
|
Loading…
Reference in New Issue
Block a user