Browse Source

GDScript: Fix crash when parsing properties

George Marques 5 years ago
parent
commit
5033d5c71c
1 changed files with 1 additions and 1 deletions
  1. 1 1
      modules/gdscript/gdscript_parser.cpp

+ 1 - 1
modules/gdscript/gdscript_parser.cpp

@@ -1355,7 +1355,7 @@ GDScriptParser::Node *GDScriptParser::parse_statement() {
 			advance();
 			advance();
 			ReturnNode *n_return = alloc_node<ReturnNode>();
 			ReturnNode *n_return = alloc_node<ReturnNode>();
 			if (!is_statement_end()) {
 			if (!is_statement_end()) {
-				if (current_function->identifier->name == GDScriptLanguage::get_singleton()->strings._init) {
+				if (current_function && current_function->identifier->name == GDScriptLanguage::get_singleton()->strings._init) {
 					push_error(R"(Constructor cannot return a value.)");
 					push_error(R"(Constructor cannot return a value.)");
 				}
 				}
 				n_return->return_value = parse_expression(false);
 				n_return->return_value = parse_expression(false);