Merge pull request #52792 from vnen/gdscript-subscript-missing-index

This commit is contained in:
Rémi Verschelde 2021-09-17 20:16:29 +02:00 committed by GitHub
commit 424ddcba37
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 0 deletions

View file

@ -2592,6 +2592,10 @@ GDScriptParser::ExpressionNode *GDScriptParser::parse_subscript(ExpressionNode *
subscript->base = p_previous_operand;
subscript->index = parse_expression(false);
if (subscript->index == nullptr) {
push_error(R"(Expected expression after "[".)");
}
pop_multiline();
consume(GDScriptTokenizer::Token::BRACKET_CLOSE, R"(Expected "]" after subscription index.)");

View file

@ -0,0 +1,3 @@
func test():
var array = [1, 2, 3]
array[] = 4

View file

@ -0,0 +1,2 @@
GDTEST_PARSER_ERROR
Expected expression after "[".