Browse Source

GDScript: Error on empty blocks at the end of file

Fix #15415
George Marques 7 years ago
parent
commit
825e85ab23
1 changed files with 6 additions and 2 deletions
  1. 6 2
      modules/gdscript/gdscript_parser.cpp

+ 6 - 2
modules/gdscript/gdscript_parser.cpp

@@ -81,8 +81,11 @@ bool GDScriptParser::_enter_indent_block(BlockNode *p_block) {
 	}
 	}
 	tokenizer->advance();
 	tokenizer->advance();
 
 
-	if (tokenizer->get_token() != GDScriptTokenizer::TK_NEWLINE) {
+	if (tokenizer->get_token() == GDScriptTokenizer::TK_EOF) {
+		return false;
+	}
 
 
+	if (tokenizer->get_token() != GDScriptTokenizer::TK_NEWLINE) {
 		// be more python-like
 		// be more python-like
 		int current = tab_level.back()->get();
 		int current = tab_level.back()->get();
 		tab_level.push_back(current);
 		tab_level.push_back(current);
@@ -92,10 +95,11 @@ bool GDScriptParser::_enter_indent_block(BlockNode *p_block) {
 	}
 	}
 
 
 	while (true) {
 	while (true) {
-
 		if (tokenizer->get_token() != GDScriptTokenizer::TK_NEWLINE) {
 		if (tokenizer->get_token() != GDScriptTokenizer::TK_NEWLINE) {
 
 
 			return false; //wtf
 			return false; //wtf
+		} else if (tokenizer->get_token(1) == GDScriptTokenizer::TK_EOF) {
+			return false;
 		} else if (tokenizer->get_token(1) != GDScriptTokenizer::TK_NEWLINE) {
 		} else if (tokenizer->get_token(1) != GDScriptTokenizer::TK_NEWLINE) {
 
 
 			int indent = tokenizer->get_token_line_indent();
 			int indent = tokenizer->get_token_line_indent();