소스 검색

GDScript: Fix match branches return check on release

The check for existence of `return` only existed on debug builds for
match branches. This could lead on an invalid error after exporting. Now
this is checked on relase too, so it works the same as the editor.
George Marques 2 년 전
부모
커밋
65407dd42d
1개의 변경된 파일1개의 추가작업 그리고 5개의 파일을 삭제
  1. 1 5
      modules/gdscript/gdscript_parser.cpp

+ 1 - 5
modules/gdscript/gdscript_parser.cpp

@@ -1906,10 +1906,8 @@ GDScriptParser::MatchNode *GDScriptParser::parse_match() {
 		return match;
 		return match;
 	}
 	}
 
 
-#ifdef DEBUG_ENABLED
 	bool all_have_return = true;
 	bool all_have_return = true;
 	bool have_wildcard = false;
 	bool have_wildcard = false;
-#endif
 
 
 	while (!check(GDScriptTokenizer::Token::DEDENT) && !is_at_end()) {
 	while (!check(GDScriptTokenizer::Token::DEDENT) && !is_at_end()) {
 		MatchBranchNode *branch = parse_match_branch();
 		MatchBranchNode *branch = parse_match_branch();
@@ -1922,21 +1920,19 @@ GDScriptParser::MatchNode *GDScriptParser::parse_match() {
 		if (have_wildcard && !branch->patterns.is_empty()) {
 		if (have_wildcard && !branch->patterns.is_empty()) {
 			push_warning(branch->patterns[0], GDScriptWarning::UNREACHABLE_PATTERN);
 			push_warning(branch->patterns[0], GDScriptWarning::UNREACHABLE_PATTERN);
 		}
 		}
+#endif
 
 
 		have_wildcard = have_wildcard || branch->has_wildcard;
 		have_wildcard = have_wildcard || branch->has_wildcard;
 		all_have_return = all_have_return && branch->block->has_return;
 		all_have_return = all_have_return && branch->block->has_return;
-#endif
 		match->branches.push_back(branch);
 		match->branches.push_back(branch);
 	}
 	}
 	complete_extents(match);
 	complete_extents(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
 	if (all_have_return && have_wildcard) {
 	if (all_have_return && have_wildcard) {
 		current_suite->has_return = true;
 		current_suite->has_return = true;
 	}
 	}
-#endif
 
 
 	return match;
 	return match;
 }
 }