Skip to content

Commit df467d6

Browse files
wgrrstrager
authored andcommitted
parse: Fix unimplemented dot semicolumn crash
Signed-off-by: wagner riffel <[email protected]>
1 parent 84e13ac commit df467d6

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

src/parse.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,7 @@ expression* parser::parse_expression_remainder(expression* ast,
942942
case token_type::minus:
943943
case token_type::plus:
944944
case token_type::question:
945+
case token_type::semicolon:
945946
case token_type::right_paren: {
946947
source_code_span empty_property_name(dot_span.end(), dot_span.end());
947948
children.back() = this->make_expression<expression::dot>(

test/test-parse-expression.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,28 @@ TEST_F(test_parse_expression, invalid_dot_expression) {
765765
error_missing_property_name_for_dot_operator, dot,
766766
offsets_matcher(p.code(), strlen(u8"x. ? y"), u8"."))));
767767
}
768+
769+
{
770+
test_parser p(u8"x.;"_sv);
771+
expression* ast = p.parse_expression();
772+
EXPECT_EQ(summarize(ast), "dot(var x, )");
773+
EXPECT_THAT(p.errors(),
774+
ElementsAre(ERROR_TYPE_FIELD(
775+
error_missing_property_name_for_dot_operator, dot,
776+
offsets_matcher(p.code(), strlen(u8"x"), u8"."))));
777+
}
778+
{
779+
test_parser p(u8".;"_sv);
780+
expression* ast = p.parse_expression();
781+
EXPECT_EQ(summarize(ast), "dot(?, )");
782+
EXPECT_THAT(
783+
p.errors(),
784+
ElementsAre(
785+
ERROR_TYPE_FIELD(error_missing_operand_for_operator, where,
786+
offsets_matcher(p.code(), 0, u8".")),
787+
ERROR_TYPE_FIELD(error_missing_property_name_for_dot_operator, dot,
788+
offsets_matcher(p.code(), 0, u8"."))));
789+
}
768790
}
769791

770792
TEST_F(test_parse_expression, parse_optional_dot_expressions) {

0 commit comments

Comments
 (0)