瀏覽代碼

Fix crash due to unreachable code in properties

Mateo de Mayo 5 年之前
父節點
當前提交
531958b2f0
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      modules/gdscript/gdscript_parser.cpp

+ 5 - 1
modules/gdscript/gdscript_parser.cpp

@@ -1421,7 +1421,11 @@ GDScriptParser::Node *GDScriptParser::parse_statement() {
 #ifdef DEBUG_ENABLED
 #ifdef DEBUG_ENABLED
 	if (unreachable) {
 	if (unreachable) {
 		current_suite->has_unreachable_code = true;
 		current_suite->has_unreachable_code = true;
-		push_warning(result, GDScriptWarning::UNREACHABLE_CODE, current_function->identifier->name);
+		if (current_function) {
+			push_warning(result, GDScriptWarning::UNREACHABLE_CODE, current_function->identifier->name);
+		} else {
+			// TODO: Properties setters and getters with unreachable code are not being warned
+		}
 	}
 	}
 #endif
 #endif