Skip to content

Commit

Permalink
Merge pull request #52792 from vnen/gdscript-subscript-missing-index
Browse files Browse the repository at this point in the history
  • Loading branch information
akien-mga authored Sep 17, 2021
2 parents 220b69a + 651319d commit 424ddcb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions modules/gdscript/gdscript_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.)");

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
func test():
var array = [1, 2, 3]
array[] = 4
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
GDTEST_PARSER_ERROR
Expected expression after "[".

0 comments on commit 424ddcb

Please sign in to comment.