[ruby/yarp] fix: parsing a '%' expression with a CR but not a newline
Previously this failed an assertion and aborted. https://github.com/ruby/yarp/commit/a037d942a8
This commit is contained in:
parent
ca6db02c2a
commit
461f8eaba7
@ -162,6 +162,12 @@ class ErrorsTest < Test::Unit::TestCase
|
||||
]
|
||||
end
|
||||
|
||||
def test_cr_without_lf_in_percent_expression
|
||||
assert_errors expression("%\r"), "%\r", [
|
||||
["Invalid %% token", 0..3],
|
||||
]
|
||||
end
|
||||
|
||||
def test_1_2_3
|
||||
assert_errors expression("(1, 2, 3)"), "(1, 2, 3)", [
|
||||
["Expected to be able to parse an expression.", 2..2],
|
||||
|
@ -6186,7 +6186,9 @@ parser_lex(yp_parser_t *parser) {
|
||||
yp_newline_list_check_append(&parser->newline_list, parser->current.end);
|
||||
|
||||
parser->current.end++;
|
||||
LEX(YP_TOKEN_STRING_BEGIN);
|
||||
if (parser->current.end < parser->end) {
|
||||
LEX(YP_TOKEN_STRING_BEGIN);
|
||||
}
|
||||
}
|
||||
|
||||
switch (*parser->current.end) {
|
||||
@ -6285,7 +6287,7 @@ parser_lex(yp_parser_t *parser) {
|
||||
// unparseable. In this case we'll just drop it from the parser
|
||||
// and skip past it and hope that the next token is something
|
||||
// that we can parse.
|
||||
yp_diagnostic_list_append(&parser->error_list, parser->current.start, parser->current.end, "invalid %% token");
|
||||
yp_diagnostic_list_append(&parser->error_list, parser->current.start, parser->current.end, "Invalid %% token");
|
||||
goto lex_next_token;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user